VectorViewMut

Trait VectorViewMut 

Source
pub trait VectorViewMut<T: ?Sized>: VectorView<T> {
    // Required method
    fn at_mut(&mut self, i: usize) -> &mut T;

    // Provided methods
    fn map_mut<F_const: for<'a> Fn(&'a T) -> &'a U, F_mut: for<'a> FnMut(&'a mut T) -> &'a mut U, U>(
        self,
        map_const: F_const,
        map_mut: F_mut,
    ) -> VectorViewMapMut<Self, T, U, F_const, F_mut>
       where Self: Sized { ... }
    fn as_slice_mut<'a>(&'a mut self) -> Option<&'a mut [T]>
       where T: Sized { ... }
    unsafe fn at_unchecked_mut<'a>(&mut self, i: usize) -> &mut T { ... }
}
Expand description

A trait for VectorViews that allow mutable access to one element at a time.

Note that a fundamental difference to many containers (like &mut [T]) is that this trait only defines functions that give a mutable reference to one element at a time. In particular, it is intentionally impossible to have a mutable reference to multiple elements at once. This enables implementations like sparse vectors, e.g. sparse::SparseMapVector.

Required Methods§

Source

fn at_mut(&mut self, i: usize) -> &mut T

Provided Methods§

Source

fn map_mut<F_const: for<'a> Fn(&'a T) -> &'a U, F_mut: for<'a> FnMut(&'a mut T) -> &'a mut U, U>( self, map_const: F_const, map_mut: F_mut, ) -> VectorViewMapMut<Self, T, U, F_const, F_mut>
where Self: Sized,

Source

fn as_slice_mut<'a>(&'a mut self) -> Option<&'a mut [T]>
where T: Sized,

If the underlying data of this VectorView can be represented as a slice, returns it. Otherwise, None is returned.

Source

unsafe fn at_unchecked_mut<'a>(&mut self, i: usize) -> &mut T

Returns a refernce to the i-th entry of the vector view, causing UB if i >= self.len().

§Safety

Same as for slice::get_unchecked_mut(). More concretely, calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, T: ?Sized, V: ?Sized + VectorViewMut<T>> VectorViewMut<T> for &'a mut V

Source§

fn at_mut(&mut self, i: usize) -> &mut T

Source§

unsafe fn at_unchecked_mut(&mut self, i: usize) -> &mut T

Source§

fn as_slice_mut<'b>(&'b mut self) -> Option<&'b mut [T]>
where T: Sized,

Source§

impl<T> VectorViewMut<T> for [T]

Source§

fn at_mut(&mut self, i: usize) -> &mut T

Source§

unsafe fn at_unchecked_mut<'a>(&mut self, i: usize) -> &mut T

Source§

fn as_slice_mut<'a>(&'a mut self) -> Option<&'a mut [T]>
where T: Sized,

Source§

impl<T, A: Allocator> VectorViewMut<T> for Vec<T, A>

Source§

fn at_mut(&mut self, i: usize) -> &mut T

Source§

unsafe fn at_unchecked_mut<'a>(&mut self, i: usize) -> &mut T

Source§

fn as_slice_mut<'a>(&'a mut self) -> Option<&'a mut [T]>
where T: Sized,

Source§

impl<T, const N: usize> VectorViewMut<T> for [T; N]

Source§

fn at_mut(&mut self, i: usize) -> &mut T

Source§

unsafe fn at_unchecked_mut<'a>(&mut self, i: usize) -> &mut T

Source§

fn as_slice_mut<'a>(&'a mut self) -> Option<&'a mut [T]>
where T: Sized,

Source§

impl<T: ?Sized, V: ?Sized + VectorViewMut<T>> VectorViewMut<T> for Box<V>

Source§

fn at_mut(&mut self, i: usize) -> &mut T

Source§

unsafe fn at_unchecked_mut<'a>(&mut self, i: usize) -> &mut T

Source§

fn as_slice_mut<'a>(&'a mut self) -> Option<&'a mut [T]>
where T: Sized,

Implementors§

Source§

impl<'a, V, T> VectorViewMut<T> for ColumnMut<'a, V, T>
where V: AsPointerToSlice<T>,

Source§

impl<R: RingStore> VectorViewMut<<<R as RingStore>::Type as RingBase>::Element> for SparseMapVector<R>

Source§

impl<V: VectorViewMut<T>, T: ?Sized> VectorViewMut<T> for StepBy<V, T>

Source§

impl<V: VectorViewMut<T>, T: ?Sized> VectorViewMut<T> for SubvectorView<V, T>

Source§

impl<V: VectorViewMut<T>, T: ?Sized, U: ?Sized, F_const: for<'a> Fn(&'a T) -> &'a U, F_mut: for<'a> FnMut(&'a mut T) -> &'a mut U> VectorViewMut<U> for VectorViewMapMut<V, T, U, F_const, F_mut>