pub struct Guard<'a, T: ForeignOwnable> { /* private fields */ }
Expand description
A lock guard.
The lock is unlocked when the guard goes out of scope.
Implementations§
Source§impl<'a, T: ForeignOwnable> Guard<'a, T>
impl<'a, T: ForeignOwnable> Guard<'a, T>
Sourcepub fn get(&self, index: usize) -> Option<T::Borrowed<'_>>
pub fn get(&self, index: usize) -> Option<T::Borrowed<'_>>
Provides a reference to the element at the given index.
Sourcepub fn get_mut(&mut self, index: usize) -> Option<T::BorrowedMut<'_>>
pub fn get_mut(&mut self, index: usize) -> Option<T::BorrowedMut<'_>>
Provides a mutable reference to the element at the given index.
Sourcepub fn remove(&mut self, index: usize) -> Option<T>
pub fn remove(&mut self, index: usize) -> Option<T>
Removes and returns the element at the given index.
Sourcepub fn store(
&mut self,
index: usize,
value: T,
gfp: Flags,
) -> Result<Option<T>, StoreError<T>>
pub fn store( &mut self, index: usize, value: T, gfp: Flags, ) -> Result<Option<T>, StoreError<T>>
Stores an element at the given index.
May drop the lock if needed to allocate memory, and then reacquire it afterwards.
On success, returns the element which was previously at the given index.
On failure, returns the element which was attempted to be stored.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for Guard<'a, T>
impl<'a, T> !RefUnwindSafe for Guard<'a, T>
impl<'a, T> !Send for Guard<'a, T>
impl<'a, T> !Sync for Guard<'a, T>
impl<'a, T> Unpin for Guard<'a, T>
impl<'a, T> !UnwindSafe for Guard<'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