Trait RawSliceMut

Source
pub trait RawSliceMut: Collection {
    // Required methods
    fn raw_slice_mut(&mut self) -> &mut [Self::Scalar];
    fn raw_set_slice(&mut self, scalars: &[Self::Scalar]);
    fn raw_set<const N: usize>(self, scalars: [Self::Scalar; N]) -> Self;
    fn with_row_major(self, scalars: &[Self::Scalar]) -> Self;
    fn with_column_major(self, scalars: &[Self::Scalar]) -> Self;

    // Provided method
    fn set<const N: usize>(self, scalars: [Self::Scalar; N]) -> Self
       where Self: Sized { ... }
}
Expand description

Trait for accessing and modifying the underlying data of a collection as a mutable slice.

Required Methods§

Source

fn raw_slice_mut(&mut self) -> &mut [Self::Scalar]

Returns a mutable reference to the underlying data as a flat array.

§Returns
  • A mutable slice of the scalar data.
Source

fn raw_set_slice(&mut self, scalars: &[Self::Scalar])

Sets the underlying data from a slice of scalars.

§Arguments
  • scalars: A slice of scalars to set the data.
§Returns
  • The modified collection with the new scalar data.
Source

fn raw_set<const N: usize>(self, scalars: [Self::Scalar; N]) -> Self

Sets the underlying data from an array of scalars.

§Arguments
  • scalars: An array of scalars to set the data.
§Returns
  • The modified collection with the new scalar data.
Source

fn with_row_major(self, scalars: &[Self::Scalar]) -> Self

Sets the underlying data from an array of scalars, assuming the input to be in row major order. The resulting data will conform to the type of matrix used - row major or column major.

§Arguments
  • scalars: An array of scalars to set the data.
§Returns
  • The modified collection with the new scalar data.

Example: If scalars = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], then internally it will be placed in memory like this: For Row major matrix: [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] For Column major matrix: [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ]

Source

fn with_column_major(self, scalars: &[Self::Scalar]) -> Self

Sets the underlying data from an array of scalars, assuming the input to be in column major order. The resulting data will conform to the type of matrix used - row major or column major.

/// # Arguments

  • scalars: An array of scalars to set the data.
§Returns
  • The modified collection with the new scalar data.

Example: If scalars = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], then internally it will be placed in memory like this: For Row major matrix: [ 1.0, 3.0, 5.0, 2.0, 4.0, 6.0 ] For Column major matrix: [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]

Provided Methods§

Source

fn set<const N: usize>(self, scalars: [Self::Scalar; N]) -> Self
where Self: Sized,

The same as from_major_row.

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.

Implementors§

Source§

impl<E, const ROWS: usize, const COLS: usize> RawSliceMut for Mat<ROWS, COLS, E, DescriptorOrderColumnMajor>
where E: MatEl, Self: Collection<Scalar = E>,

Source§

impl<E, const ROWS: usize, const COLS: usize> RawSliceMut for Mat<ROWS, COLS, E, DescriptorOrderRowMajor>
where E: MatEl, Self: Collection<Scalar = E>,