Struct asciimath_parser::tree::Matrix
source · pub struct Matrix<'a> {
pub left_bracket: &'a str,
pub right_bracket: &'a str,
/* private fields */
}
Expand description
A matrix e.g. “[[a, b], [x, y]]”
Individual expressions can be accessed with rows to get a random access iterator of row
slices, or by indexing with a 2d array of indices, e.g. matrix[[0, 0]]
Fields§
§left_bracket: &'a str
The matrix’s left bracket
right_bracket: &'a str
The matrix’s right bracket
Implementations§
source§impl<'a> Matrix<'a>
impl<'a> Matrix<'a>
sourcepub fn new<E>(
left_bracket: &'a str,
cells: E,
num_cols: usize,
right_bracket: &'a str
) -> Selfwhere
E: Into<Box<[Expression<'a>]>>,
pub fn new<E>( left_bracket: &'a str, cells: E, num_cols: usize, right_bracket: &'a str ) -> Selfwhere E: Into<Box<[Expression<'a>]>>,
Create a new matrix
cells
is a slice of expressiongs in row-major top-down order. num_cols
is how many
columns exist in the final matrix.
Panics
When cells.into().len()
is not divisible by num_cols
.
sourcepub fn rows(&self) -> MatrixRows<'a, '_> ⓘ
pub fn rows(&self) -> MatrixRows<'a, '_> ⓘ
A top-down iterator over rows as slices
Trait Implementations§
source§impl<'a, 'b> IntoIterator for &'b Matrix<'a>
impl<'a, 'b> IntoIterator for &'b Matrix<'a>
Matrix references iterate over rows