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

Method get_weakrefs

crates/vm/src/object/core.rs:1326–1340  ·  view source on GitHub ↗

Returns the first weakref in the weakref list, if any.

(&self)

Source from the content-addressed store, hash-verified

1324
1325 /// Returns the first weakref in the weakref list, if any.
1326 pub(crate) fn get_weakrefs(&self) -> Option<PyObjectRef> {
1327 let wrl = self.weak_ref_list()?;
1328 let _lock = weakref_lock::lock(self as *const PyObject as usize);
1329 let head_ptr = wrl.head.load(Ordering::Relaxed);
1330 if head_ptr.is_null() {
1331 None
1332 } else {
1333 let head = unsafe { &*head_ptr };
1334 if head.0.ref_count.safe_inc() {
1335 Some(unsafe { PyRef::from_raw(head_ptr) }.into())
1336 } else {
1337 None
1338 }
1339 }
1340 }
1341
1342 pub(crate) fn downgrade_with_weakref_typ_opt(
1343 &self,

Callers 1

subtype_get_weakrefFunction · 0.80

Calls 5

lockFunction · 0.85
weak_ref_listMethod · 0.80
safe_incMethod · 0.80
SomeClass · 0.50
loadMethod · 0.45

Tested by

no test coverage detected