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

Method new_owned

crates/vm/src/object/core.rs:1883–1894  ·  view source on GitHub ↗
(obj: PyObjectRef)

Source from the content-addressed store, hash-verified

1881 /// Refcount is NOT incremented — ownership is transferred.
1882 #[inline(always)]
1883 pub fn new_owned(obj: PyObjectRef) -> Self {
1884 let ptr = obj.into_raw();
1885 let bits = ptr.as_ptr() as usize;
1886 debug_assert!(
1887 bits & STACKREF_BORROW_TAG == 0,
1888 "PyObject pointer must be aligned"
1889 );
1890 Self {
1891 // SAFETY: valid PyObject pointers are never null
1892 bits: unsafe { NonZeroUsize::new_unchecked(bits) },
1893 }
1894 }
1895
1896 /// Create a borrowed stack reference from a `&PyObject`.
1897 ///

Callers

nothing calls this directly

Calls 2

into_rawMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected