Skip to main content

VecMut

Struct VecMut 

Source
pub struct VecMut<'a, T> { /* private fields */ }
Expand description

A reference to a single column/row of a matrix.

This is similar to &[T] but with a pitch potentially different from 1 between its elements, i.e. there is no guarantee of contiguity. As a consequence this does not have a simple past-the-end pointer like a slice would have. For an empty slice the only guaranteed-valid pointer is the base pointer itself while for larger slices the last guaranteed-valid pointer is one-past the last element, not one additional pitch.

Created from its constructors or a block reference via the BlockMut::col and BlockMut::row methods.

Implementations§

Source§

impl<'data, T> VecMut<'data, T>

Source

pub fn new(data: &'data mut [T], pitch: usize) -> Self

Create a new vector reference from a raw slice and pitch.

The resulting block refers to the first column of the matrix.

Source

pub fn from_slice(data: &'data mut [T]) -> Self

Create a new vector reference from a raw slice with pitch 1.

Source

pub fn len(&self) -> usize

Number of elements in this vector.

Source

pub fn is_empty(&self) -> bool

Whether this vector is empty.

Source

pub fn split_at(self, mid: usize) -> (VecMut<'data, T>, VecMut<'data, T>)

Divide into two vectors at the given element.

§Examples
use matrix_slice::VecMut;

let data = &mut [0, 1, 2, 3, 4, 5];

let block = VecMut::new(data, 1);
let (left, right) = block.split_at(2);

assert_eq!(left[1], 1);
assert_eq!(right[3], 5);
Source

pub fn split_at_checked( self, mid: usize, ) -> Option<(VecMut<'data, T>, VecMut<'data, T>)>

Divide into two vectors at the given element.

See Self::split_at but returns None if out of bounds.

Source

pub fn select<R>(self, range: R) -> Option<VecMut<'data, T>>
where R: MatrixIndex,

Choose a range of elements and contract the vector to that.

Source

pub fn cast_const(self) -> VecRef<'data, T>

Turn this unique reference into a shared reference.

Source

pub fn reborrow(&mut self) -> VecMut<'_, T>

Create a unique reference to this block with a shorter lifetime.

Source

pub fn as_cells(self) -> VecMut<'data, Cell<T>>

Modify the item type to a Cell, allowing interior mutability.

This is the equivalent of Cell::from_mut over elements in this slice.

Source§

impl<'data, T> VecMut<'data, Cell<T>>

Source

pub fn as_cell_items(self) -> VecMut<'data, T>

Modify the item type from a Cell to its interior type.

This is the equivalent of Cell::get_mut over elements in this slice.

Trait Implementations§

Source§

impl<T> Index<usize> for VecMut<'_, T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<usize> for VecMut<'_, T>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> Send for VecMut<'_, T>
where T: Sync,

Source§

impl<T> Sync for VecMut<'_, T>
where T: Sync,

Auto Trait Implementations§

§

impl<'a, T> Freeze for VecMut<'a, T>

§

impl<'a, T> RefUnwindSafe for VecMut<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Unpin for VecMut<'a, T>

§

impl<'a, T> !UnwindSafe for VecMut<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.