pub struct Cell<T> { /* private fields */ }Expand description
Implements a thread safe data structure which can be used to temporary borrow an inner value.
Implementations§
Source§impl<T> Cell<T>
impl<T> Cell<T>
pub fn new(value: T) -> Self
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Returns true if the inner value is available to borrow. Returns false if value already
borrowed.
§Panics
Will panic if failed to lock the inner variable.
Sourcepub fn try_borrow(&self) -> Option<Borrowed<T>>
pub fn try_borrow(&self) -> Option<Borrowed<T>>
Tries to borrow the inner value. Will return None if inner value couldn’t be borrowed.
§Panics
Will panic if failed to lock the inner variable.
Auto Trait Implementations§
impl<T> Freeze for Cell<T>
impl<T> RefUnwindSafe for Cell<T>
impl<T> Send for Cell<T>where
T: Send,
impl<T> Sync for Cell<T>where
T: Send,
impl<T> Unpin for Cell<T>
impl<T> UnwindSafe for Cell<T>
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