pub struct WriteGuard<'a, T> { /* private fields */ }Expand description
The data should always be replaced completely. Incremental updates can lead to the reader seeing inconsistent data, as the data structure uses two copies of the data internally and alternates between writing to both of them. The copies will start to diverge when doing changes instead of replacing it.
I still offer DerefMut instead of just taking a new T, because this allows reusing allocations inside of T instead of dropping and reallocing. This is important for realtime usecases.
Trait Implementations§
Source§impl<T> Deref for WriteGuard<'_, T>
impl<T> Deref for WriteGuard<'_, T>
Source§impl<T> DerefMut for WriteGuard<'_, T>
impl<T> DerefMut for WriteGuard<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for WriteGuard<'a, T>
impl<'a, T> !RefUnwindSafe for WriteGuard<'a, T>
impl<'a, T> Send for WriteGuard<'a, T>
impl<'a, T> !Sync for WriteGuard<'a, T>
impl<'a, T> Unpin for WriteGuard<'a, T>
impl<'a, T> !UnwindSafe for WriteGuard<'a, 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