MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / with_borrowed_ptr

Method with_borrowed_ptr

src/conversion.rs:55–63  ·  view source on GitHub ↗
(&self, py: Python, f: F)

Source from the content-addressed store, hash-verified

53 /// to touch any reference counts when the input object already is a Python object.
54 #[inline]
55 fn with_borrowed_ptr<F, R>(&self, py: Python, f: F) -> R
56 where
57 F: FnOnce(*mut ffi::PyObject) -> R,
58 {
59 let obj = self.to_py_object(py).into_object();
60 let res = f(obj.as_ptr());
61 obj.release_ref(py);
62 res
63 }
64
65 // FFI functions that accept a borrowed reference will use:
66 // input.with_borrowed_ptr(|obj| ffi::Call(obj)

Callers

nothing calls this directly

Implementers 9

conversion.rssrc/conversion.rs
dict.rssrc/objects/dict.rs
string.rssrc/objects/string.rs
num.rssrc/objects/num.rs
tuple.rssrc/objects/tuple.rs
none.rssrc/objects/none.rs
list.rssrc/objects/list.rs
set.rssrc/objects/set.rs
boolobject.rssrc/objects/boolobject.rs

Calls 5

fFunction · 0.85
into_objectMethod · 0.45
to_py_objectMethod · 0.45
as_ptrMethod · 0.45
release_refMethod · 0.45

Tested by

no test coverage detected