Struct bacon_rajan_cc::Weak
source · pub struct Weak<T: Trace> { /* private fields */ }
Expand description
A weak version of Cc<T>
.
Weak references do not count when determining if the inner value should be dropped.
See the module level documentation for more.
Implementations§
source§impl<T: Trace> Weak<T>
impl<T: Trace> Weak<T>
sourcepub fn upgrade(&self) -> Option<Cc<T>>
pub fn upgrade(&self) -> Option<Cc<T>>
Upgrades a weak reference to a strong reference.
Upgrades the Weak<T>
reference to an Cc<T>
, if possible.
Returns None
if there were no strong references and the data was
destroyed.
Examples
use bacon_rajan_cc::Cc;
let five = Cc::new(5);
let weak_five = five.downgrade();
let strong_five: Option<Cc<_>> = weak_five.upgrade();
Trait Implementations§
source§impl<T: Trace> Drop for Weak<T>
impl<T: Trace> Drop for Weak<T>
source§fn drop(&mut self)
fn drop(&mut self)
Drops the Weak<T>
.
This will decrement the weak reference count.
Examples
use bacon_rajan_cc::Cc;
{
let five = Cc::new(5);
let weak_five = five.downgrade();
// stuff
drop(weak_five); // explicit drop
}
{
let five = Cc::new(5);
let weak_five = five.downgrade();
// stuff
} // implicit drop