pub struct VecRefMut<'a, T: ?Sized> { /* private fields */ }Expand description
Wraps a mutably borrowed value from a VecCell.
Implementations§
Source§impl<'a, T: ?Sized> VecRefMut<'a, T>
impl<'a, T: ?Sized> VecRefMut<'a, T>
Sourcepub fn get(&self) -> &T
pub fn get(&self) -> &T
Returns an immutable reference to the borrowed value.
The reference may not outlive this VecRefMut instance.
§Example
let mut vec: VecCell<String> = VecCell::new();
vec.push(String::from("hello"));
vec.push(String::from("world"));
let guard = vec.borrow_mut(0).unwrap();
assert_eq!(guard.get(), "hello");Sourcepub fn map<'b, U: ?Sized, F>(
original: VecRefMut<'b, T>,
f: F,
) -> VecRefMut<'b, U>
pub fn map<'b, U: ?Sized, F>( original: VecRefMut<'b, T>, f: F, ) -> VecRefMut<'b, U>
Transforms a VecRefMut<'_, T> into a VecRefMut<'_, U> from a function that maps &mut T to &mut U.
This function does not use self and must be called explicitly via VecRefMut::map(value, function).
§Examples
fn return_favorite_value_mut<'a>(array: &'a VecCell<Vec<u8>>) -> VecRefMut<'a, u8> {
VecRefMut::map(array.borrow_mut(42).unwrap(), |vec| &mut vec[7])
}Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for VecRefMut<'a, T>where
T: ?Sized,
impl<'a, T> !RefUnwindSafe for VecRefMut<'a, T>
impl<'a, T> !Send for VecRefMut<'a, T>
impl<'a, T> !Sync for VecRefMut<'a, T>
impl<'a, T> Unpin for VecRefMut<'a, T>where
T: ?Sized,
impl<'a, T> !UnwindSafe for VecRefMut<'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