Struct rccell::WeakCell [−][src]
pub struct WeakCell<T>(_);
Expand description
Version of RefCell
that holds a non-owning reference to the managed allocation.
Implementations
Constructs a new WeakCell<T>
, without allocating any memory.
Calling WeakCell::upgrade on the return value always gives None.
Examples
use rccell::WeakCell;
let empty: WeakCell<i32> = WeakCell::new();
assert!(empty.upgrade().is_none());
Similar to Weak::upgrade.
Attempts to upgrade the WeakCell
pointer to an RcCell
.
Returns None
if the inner value has been dropped.
Examples
use rccell::RcCell;
let five = RcCell::new(5);
let weak_five = five.downgrade();
let strong_five = weak_five.upgrade();
assert!(strong_five.is_some());
drop(strong_five);
drop(five);
assert!(weak_five.upgrade().is_none());
Gets the number of strong (RcCell
) pointers pointing to this allocation.
If self
was created using WeakCell::new, this will return 0.
Gets the number of WeakCell
pointers pointing to this allocation.
If no strong pointers remain, this will return 0.
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for WeakCell<T>
impl<T> !UnwindSafe for WeakCell<T>
Blanket Implementations
Mutably borrows from an owned value. Read more