MCPcopy Create free account
hub / github.com/SSheldon/rust-objc / new

Method new

src/rc/weak.rs:18–22  ·  view source on GitHub ↗

Constructs a `WeakPtr` to the given object. Unsafe because the caller must ensure the given object pointer is valid.

(obj: *mut Object)

Source from the content-addressed store, hash-verified

16 /// Constructs a `WeakPtr` to the given object.
17 /// Unsafe because the caller must ensure the given object pointer is valid.
18 pub unsafe fn new(obj: *mut Object) -> Self {
19 let ptr = Box::new(UnsafeCell::new(ptr::null_mut()));
20 runtime::objc_initWeak(ptr.get(), obj);
21 WeakPtr(ptr)
22 }
23
24 /// Loads the object self points to, returning a `StrongPtr`.
25 /// If the object has been deallocated, the returned pointer will be null.

Callers

nothing calls this directly

Calls 2

WeakPtrClass · 0.85
getMethod · 0.80

Tested by

no test coverage detected