pub struct ElementGuard<'a, T> { /* private fields */ }Expand description
A guard providing mutable access to a single element.
An ElementGuard is returned by ElementHandle::lock. While an
ElementGuard is alive:
- No
ArrayGuard<T>can be acquired. - No other
ElementGuardfor the same element can exist.
Guards for different elements may coexist concurrently.
The guard dereferences to &mut T, allowing direct mutation of the
underlying element.
§RAII Semantics
The element-level lock is released automatically when this guard is dropped. This ensures that access is tied to the lifetime of the guard.
§Examples
let data = vec![0];
let (_, mut elements) = bimodal_array(data);
let mut guard = elements[0].lock().unwrap();
*guard = 42;
// Lock is released here when `guard` is dropped.Trait Implementations§
Source§impl<'a, T> Deref for ElementGuard<'a, T>
impl<'a, T> Deref for ElementGuard<'a, T>
Source§impl<'a, T> DerefMut for ElementGuard<'a, T>
impl<'a, T> DerefMut for ElementGuard<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for ElementGuard<'a, T>
impl<'a, T> RefUnwindSafe for ElementGuard<'a, T>where
T: RefUnwindSafe,
impl<'a, T> !Send for ElementGuard<'a, T>
impl<'a, T> !Sync for ElementGuard<'a, T>
impl<'a, T> Unpin for ElementGuard<'a, T>
impl<'a, T> UnsafeUnpin for ElementGuard<'a, T>
impl<'a, T> UnwindSafe for ElementGuard<'a, 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