DrMatrixRowConstructor

Struct DrMatrixRowConstructor 

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

Constructs a new valid row in a easy and interactive manner.

This struct may panic when out of scope. Please see the Drop documentation in the Trait Implementations section for more information. #[derive(Debug, PartialEq)]

Implementations§

Source§

impl<'a, DS> DrMatrixRowConstructor<'a, DS>
where DS: DynDenseStoMut,

Source

pub fn clone_values_from_row(self, row: &[DS::Item]) -> Self
where DS::Item: Clone,

Clones all values of row into the current row.

§Examples
use mop_structs::{
    doc_tests::dr_matrix_empty_vec_array,
    matrix::dr_matrix::DrMatrixRef
};
let mut a = dr_matrix_empty_vec_array();
a.row_constructor().copy_values_from_row(&[1, 2, 3, 4, 5]).commit();
assert_eq!(a.as_ref(), DrMatrixRef::new(
    [1, 5],
    &[1, 2, 3, 4, 5],
));
Source

pub fn commit(self)

Commits the row construction, modifying the internal structure.

§Examples
use mop_structs::{
    doc_tests::dr_matrix_empty_vec_array,
    matrix::dr_matrix::DrMatrixRef
};
let mut a = dr_matrix_empty_vec_array();
a.row_constructor()
    .push_value(1)
    .push_value(2)
    .push_value(3)
    .push_value(4)
    .push_value(5)
    .commit();
assert_eq!(a.as_ref(), DrMatrixRef::new([1, 5], &[1, 2, 3, 4, 5]));
§Assertions
  • The number of inserted elements must be equal the number of columns of Self.
use mop_structs::doc_tests::dr_matrix_empty_vec_array;
let mut a = dr_matrix_empty_vec_array();
a.row_constructor().push_value(1).commit();
Source

pub fn copy_values_from_row(self, row: &[DS::Item]) -> Self
where DS::Item: Copy,

Copies all values of row into the current row.

§Examples
use mop_structs::{
    doc_tests::dr_matrix_empty_vec_array,
    matrix::dr_matrix::DrMatrixRef
};
let mut a = dr_matrix_empty_vec_array();
a.row_constructor().copy_values_from_row(&[1, 2, 3, 4, 5]).commit();
assert_eq!(a.as_ref(), DrMatrixRef::new(
    [1, 5],
    &[1, 2, 3, 4, 5],
));
Source

pub fn push_value(self, value: DS::Item) -> Self

Pushes a new value.

§Examples
use mop_structs::{
    doc_tests::{dr_matrix_empty_vec_array, dr_matrix_array},
};
let mut a = dr_matrix_empty_vec_array();
a.row_constructor()
    .push_value(1)
    .push_value(2)
    .push_value(3)
    .push_value(4)
    .push_value(5)
    .commit();
a.row_constructor()
    .push_value(6)
    .push_value(7)
    .push_value(8)
    .push_value(9)
    .push_value(10)
    .commit();
a.row_constructor()
    .push_value(11)
    .push_value(12)
    .push_value(13)
    .push_value(14)
    .push_value(15)
    .commit();
a.row_constructor()
    .push_value(16)
    .push_value(17)
    .push_value(18)
    .push_value(19)
    .push_value(20)
    .commit();
assert_eq!(a.as_ref(), dr_matrix_array().as_ref());

Trait Implementations§

Source§

impl<'a, DS: Debug> Debug for DrMatrixRowConstructor<'a, DS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, DS> Drop for DrMatrixRowConstructor<'a, DS>

Source§

fn drop(&mut self)

Some measures are taken to ensure a valid format and avoid unexpected runtime behavior.

§Assertions
  • Every single nonempty instance of DrMatrixRowConstructor must end with a call to the commit method.
use mop_structs::doc_tests::dr_matrix_empty_vec_array;
let mut a = dr_matrix_empty_vec_array();
a.row_constructor().push_value(1).push_value(2).push_value(3).push_value(4);
Source§

impl<'a, DS: PartialEq> PartialEq for DrMatrixRowConstructor<'a, DS>

Source§

fn eq(&self, other: &DrMatrixRowConstructor<'a, DS>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, DS> StructuralPartialEq for DrMatrixRowConstructor<'a, DS>

Auto Trait Implementations§

§

impl<'a, DS> Freeze for DrMatrixRowConstructor<'a, DS>

§

impl<'a, DS> RefUnwindSafe for DrMatrixRowConstructor<'a, DS>
where DS: RefUnwindSafe,

§

impl<'a, DS> Send for DrMatrixRowConstructor<'a, DS>
where DS: Send,

§

impl<'a, DS> Sync for DrMatrixRowConstructor<'a, DS>
where DS: Sync,

§

impl<'a, DS> Unpin for DrMatrixRowConstructor<'a, DS>

§

impl<'a, DS> !UnwindSafe for DrMatrixRowConstructor<'a, DS>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.