pub struct LockMut<T>(/* private fields */);Expand description
This datatype provides a lock with interior mutability for the data inside.
Implementations§
Source§impl<T> LockMut<T>
impl<T> LockMut<T>
Sourcepub fn try_with_lock<F: FnOnce(&mut T)>(&self, f: F)
pub fn try_with_lock<F: FnOnce(&mut T)>(&self, f: F)
Locks if this LockMut is initialized, then runs
the closure f with a mutable reference to the
locked data. If the LockMut is uninitialized,
this method does nothing.
§Examples
static LOCKED_DATA: LockMut<u8> = LockMut::new();
LOCKED_DATA.try_with_lock(|_| panic!());Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for LockMut<T>
impl<T> !RefUnwindSafe for LockMut<T>
impl<T> Send for LockMut<T>where
T: Send,
impl<T> Sync for LockMut<T>where
T: Send,
impl<T> Unpin for LockMut<T>where
T: Unpin,
impl<T> UnwindSafe for LockMut<T>where
T: UnwindSafe,
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