pub struct VecRefMut<'a, T: ?Sized> { /* private fields */ }
Expand description

Wraps a mutably borrowed value from a VecCell.

Implementations

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");

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])
}

Variant of VecRefMut::map, where the callback (f) may fail.

f must return a Result; if it returns Ok(x), then try_map returns Ok(VecRefMut(x)). Otherwise, it returns Err(err).

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.