pub struct TinyWeak<T>(/* private fields */);Expand description
A weak reference to a TinyArc, which is a thread-safe reference-counting tiny pointer.
Essentially, it is non owning, and can be upgraded to a TinyArc at any time to access the
data.
§Example
use tinypointers::TinyArc;
let owned = TinyArc::new(42);
let non_owned = TinyArc::downgrade(&owned);
assert_eq!(*owned, 42);
assert_eq!(*non_owned.upgrade(), 42);Implementations§
Source§impl<T> TinyWeak<T>
impl<T> TinyWeak<T>
Sourcepub fn upgrade(&self) -> TinyArc<T>
pub fn upgrade(&self) -> TinyArc<T>
Attempts to upgrade the TinyWeak pointer to an TinyArc, extending the lifetime of the
data if successful.
§Example
use tinypointers::TinyArc;
let owned = TinyArc::new(42);
let non_owned = TinyArc::downgrade(&owned);
drop(owned);
let owned = non_owned.upgrade(); // Panics§Panics
This panics if the data has since been dropped. I.E. if the TinyArc count is zero.
Trait Implementations§
impl<T: Send + Sync> Send for TinyWeak<T>
impl<T: Send + Sync> Sync for TinyWeak<T>
Auto Trait Implementations§
impl<T> Freeze for TinyWeak<T>
impl<T> RefUnwindSafe for TinyWeak<T>where
T: RefUnwindSafe,
impl<T> Unpin for TinyWeak<T>
impl<T> UnwindSafe for TinyWeak<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more