pub struct EntryWriteGuard<'a, T> { /* private fields */ }Expand description
Holds a write guard to the entry. See Entry::write().
Implementations§
Source§impl<T: 'static> EntryWriteGuard<'_, T>
impl<T: 'static> EntryWriteGuard<'_, T>
Sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Acquires a mutable reference to the entry.
Examples found in repository?
examples/registry_mutation.rs (line 17)
3fn main() {
4 let registry = Registry::<i32>::new();
5 let entry1 = registry.register(0);
6 let entry2 = registry.register(100);
7
8 println!("{:?}", registry); // Prints: {0: 0, 1: 100}
9
10 println!("Mutation via Registry...");
11 for (_, value) in registry.write().iter_mut() {
12 *value += 1;
13 }
14 println!("{:?}", registry); // Prints: {0: 1, 1: 101}
15
16 println!("Mutation via typed Entry...");
17 *entry1.write().unwrap().get_mut() += 10;
18 *entry2.write().unwrap().get_mut() += 10;
19 println!("{:?}", registry); // Prints: {0: 11, 1: 111}
20}Auto Trait Implementations§
impl<'a, T> Freeze for EntryWriteGuard<'a, T>
impl<'a, T> RefUnwindSafe for EntryWriteGuard<'a, T>where
T: RefUnwindSafe,
impl<'a, T> !Send for EntryWriteGuard<'a, T>
impl<'a, T> Sync for EntryWriteGuard<'a, T>where
T: Sync,
impl<'a, T> Unpin for EntryWriteGuard<'a, T>where
T: Unpin,
impl<'a, T> UnsafeUnpin for EntryWriteGuard<'a, T>
impl<'a, T> UnwindSafe for EntryWriteGuard<'a, 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