MCPcopy Index your code
hub / github.com/RustPython/RustPython / try_to_owned_from_ptr

Method try_to_owned_from_ptr

crates/vm/src/object/core.rs:1231–1241  ·  view source on GitHub ↗
(ptr: *mut Self)

Source from the content-addressed store, hash-verified

1229 /// (same guarantee as `_Py_TryIncRefShared`).
1230 #[inline]
1231 pub unsafe fn try_to_owned_from_ptr(ptr: *mut Self) -> Option<PyObjectRef> {
1232 let inner = ptr.cast::<PyInner<Erased>>();
1233 let ref_count = unsafe { &*core::ptr::addr_of!((*inner).ref_count) };
1234 if ref_count.safe_inc() {
1235 Some(PyObjectRef {
1236 ptr: unsafe { NonNull::new_unchecked(ptr) },
1237 })
1238 } else {
1239 None
1240 }
1241 }
1242}
1243
1244impl PyObjectRef {

Callers

nothing calls this directly

Calls 2

safe_incMethod · 0.80
SomeClass · 0.50

Tested by

no test coverage detected