pub struct Matrix<T, const M: usize, const N: usize>where
T: Copy,{ /* private fields */ }
Expand description
A 2D array of values which can be operated upon.
Matrices have a fixed size known at compile time
Implementations§
Source§impl<T: Copy, const N: usize> Matrix<T, N, 1>
Operations for column vectors
impl<T: Copy, const N: usize> Matrix<T, N, 1>
Operations for column vectors
Sourcepub fn dot<R>(&self, rhs: &R) -> T
pub fn dot<R>(&self, rhs: &R) -> T
Compute the dot product of two vectors, otherwise known as the scalar product.
This is the sum of the elementwise product, or in math terms
$vec(a) * vec(b) = sum_(i=1)^n a_i b_i = a_1 b_1 + a_2 b_2 + … + a_n b_n$
for example, $[[1],[2],[3]] * [[4],[5],[6]] = (1 * 4) + (2 * 5) + (3 * 6) = 32$
For vectors in euclidean space, this has the property that it is equal to the magnitudes of the vectors times the cosine of the angle between them.
$vec(a) * vec(b) = |vec(a)| |vec(b)| cos(theta)$
this also gives it the special property that the dot product of a vector and itself is the square of its magnitude. You may recognize the 2D version as the pythagorean theorem.
see dot product on Wikipedia for more information.
pub fn sqrmag(&self) -> T
pub fn mag(&self) -> T
pub fn normalized(&self) -> Option<Self>
Source§impl<T: Copy, const M: usize, const N: usize> Matrix<T, M, N>
Operations for Matrices
impl<T: Copy, const M: usize, const N: usize> Matrix<T, M, N>
Operations for Matrices
Source§impl<T: Copy + Zero + One, const N: usize> Matrix<T, N, N>
impl<T: Copy + Zero + One, const N: usize> Matrix<T, N, N>
Sourcepub fn identity() -> Self
pub fn identity() -> Self
Create an identity matrix, a square matrix where the diagonals are 1 and all other elements are 0.
for example,
$bbI = [[1,0,0],[0,1,0],[0,0,1]]$
Matrix multiplication between a matrix and the identity matrix always results in itself
$bbA xx bbI = bbA$
§Examples
let i = Matrix::<i32,3,3>::identity();
assert_eq!(i, Matrix::mat([[1, 0, 0],
[0, 1, 0],
[0, 0, 1]]))
Note that the identity only exists for matrices that are square, so this doesnt work:
let i = Matrix::<i32,4,2>::identity();
Source§impl<T: Copy, const M: usize, const N: usize> Matrix<T, M, N>
impl<T: Copy, const M: usize, const N: usize> Matrix<T, M, N>
Sourcepub fn from_rows<I>(iter: I) -> Self
pub fn from_rows<I>(iter: I) -> Self
Create a matrix from an iterator of vectors
§Arguments
iter
: iterator of vectors to copy into rows
§Examples
The following is another way of performing Matrix::transpose()
let my_matrix = Matrix::mat([[1, 2, 3],
[4, 5, 6]]);
let transpose : Matrix<_,3,2>= Matrix::from_rows(my_matrix.cols());
assert_eq!(transpose, Matrix::mat([[1, 4],
[2, 5],
[3, 6]]))
Sourcepub fn from_cols<I>(iter: I) -> Self
pub fn from_cols<I>(iter: I) -> Self
Create a matrix from an iterator of vectors
§Arguments
iter
: iterator of vectors to copy into columns
§Examples
The following is another way of performing Matrix::transpose()
let my_matrix = Matrix::mat([[1, 2, 3],
[4, 5, 6]]);
let transpose : Matrix<_,3,2>= Matrix::from_cols(my_matrix.rows());
assert_eq!(transpose, Matrix::mat([[1, 4],
[2, 5],
[3, 6]]))
Source§impl<T: Copy, const M: usize, const N: usize> Matrix<T, M, N>
impl<T: Copy, const M: usize, const N: usize> Matrix<T, M, N>
Sourcepub fn elements<'s>(&'s self) -> impl Iterator<Item = &'s T> + 's
pub fn elements<'s>(&'s self) -> impl Iterator<Item = &'s T> + 's
Returns an iterator over the elements of the matrix in row-major order.
This is identical to the behavior of IntoIterator
§Examples
let my_matrix = Matrix::mat([[1, 2],
[3, 4]]);
itertools::assert_equal(my_matrix.elements(), [1,2,3,4].iter())
Sourcepub fn elements_mut<'s>(&'s mut self) -> impl Iterator<Item = &'s mut T> + 's
pub fn elements_mut<'s>(&'s mut self) -> impl Iterator<Item = &'s mut T> + 's
Returns a mutable iterator over the elements of the matrix in row-major order.
§Examples
let mut my_matrix = Matrix::mat([[1, 2],
[3, 4]]);
for elem in my_matrix.elements_mut() {*elem += 2;}
itertools::assert_equal(my_matrix.elements(), [3,4,5,6].iter())
Sourcepub fn diagonals<'s>(&'s self) -> impl Iterator<Item = &'s T> + 's
pub fn diagonals<'s>(&'s self) -> impl Iterator<Item = &'s T> + 's
returns an iterator over the elements along the diagonal of a matrix
§Examples
let my_matrix = Matrix::mat([[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[10,11,12]]);
itertools::assert_equal(my_matrix.diagonals(), [1,5,9].iter())
Sourcepub fn subdiagonals<'s>(&'s self) -> impl Iterator<Item = &'s T> + 's
pub fn subdiagonals<'s>(&'s self) -> impl Iterator<Item = &'s T> + 's
Returns an iterator over the elements directly below the diagonal of a matrix
§Examples
let my_matrix = Matrix::mat([[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[10,11,12]]);
itertools::assert_equal(my_matrix.subdiagonals(), [4,8,12].iter());
Sourcepub fn get(&self, index: impl MatrixIndex) -> Option<&T>
pub fn get(&self, index: impl MatrixIndex) -> Option<&T>
Returns a reference to the element at that position in the matrix, or None
if out of bounds.
Index
behaves similarly,
but will panic if the index is out of bounds instead of returning an option
§Arguments
index
: a 1D or 2D index into the matrix. See MatrixIndex for more information on matrix indexing.
§Examples
let my_matrix = Matrix::mat([[1, 2],
[3, 4]]);
// element at index 2 is the same as the element at row 1, column 0.
assert_eq!(my_matrix.get(2), my_matrix.get((1,0)));
// my_matrix.get() is equivalent to my_matrix[],
// but returns an Option instead of panicking
assert_eq!(my_matrix.get(2), Some(&my_matrix[2]));
// index 4 is out of range, so get(4) returns None.
assert_eq!(my_matrix.get(4), None);
Sourcepub fn get_mut(&mut self, index: impl MatrixIndex) -> Option<&mut T>
pub fn get_mut(&mut self, index: impl MatrixIndex) -> Option<&mut T>
Returns a mutable reference to the element at that position in the matrix,
or None
if out of bounds.
IndexMut
behaves similarly,
but will panic if the index is out of bounds instead of returning an option
§Arguments
index
: a 1D or 2D index into the matrix. See MatrixIndex for more information on matrix indexing.
§Examples
let mut my_matrix = Matrix::mat([[1, 2],
[3, 4]]);
match my_matrix.get_mut(2) {
Some(t) => *t = 5,
None => panic!()};
assert_eq!(my_matrix, Matrix::mat([[1,2],[5,4]]))
Sourcepub fn rows<'a>(&'a self) -> impl Iterator<Item = Vector<T, N>> + 'a
pub fn rows<'a>(&'a self) -> impl Iterator<Item = Vector<T, N>> + 'a
Returns an iterator over the rows of the matrix, returning them as column vectors.
Sourcepub fn cols<'a>(&'a self) -> impl Iterator<Item = Vector<T, M>> + 'a
pub fn cols<'a>(&'a self) -> impl Iterator<Item = Vector<T, M>> + 'a
Returns an iterator over the columns of the matrix, returning them as column vectors.
Sourcepub fn permute_rows<const P: usize>(
&self,
ms: &Vector<usize, P>,
) -> Matrix<T, P, N>where
T: Default,
pub fn permute_rows<const P: usize>(
&self,
ms: &Vector<usize, P>,
) -> Matrix<T, P, N>where
T: Default,
Apply a permutation matrix to the rows of a matrix
§Arguments
ms
: aVector
ofusize
of length P. Each entry is the index of the row that will appear in the result
Returns: a P×N matrix
§Panics
Panics if any of the row indices in ms
is out of bounds
§Examples
let my_matrix = Matrix::mat([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]);
let permuted = my_matrix.permute_rows(&Vector::vec([1, 0, 2]));
assert_eq!(permuted, Matrix::mat([[4, 5, 6],
[1, 2, 3],
[7, 8, 9]]))
Sourcepub fn permute_cols<const P: usize>(
&self,
ns: &Vector<usize, P>,
) -> Matrix<T, M, P>where
T: Default,
pub fn permute_cols<const P: usize>(
&self,
ns: &Vector<usize, P>,
) -> Matrix<T, M, P>where
T: Default,
Trait Implementations§
Source§impl<L, R, const M: usize, const N: usize> AddAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> AddAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn add_assign(&mut self, other: &Matrix<R, M, N>)
fn add_assign(&mut self, other: &Matrix<R, M, N>)
+=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> AddAssign<Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> AddAssign<Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn add_assign(&mut self, other: Matrix<R, M, N>)
fn add_assign(&mut self, other: Matrix<R, M, N>)
+=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> AddAssign<R> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> AddAssign<R> for Matrix<L, M, N>
Source§fn add_assign(&mut self, r: R)
fn add_assign(&mut self, r: R)
+=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> BitAndAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> BitAndAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn bitand_assign(&mut self, other: &Matrix<R, M, N>)
fn bitand_assign(&mut self, other: &Matrix<R, M, N>)
&=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> BitAndAssign<Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> BitAndAssign<Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn bitand_assign(&mut self, other: Matrix<R, M, N>)
fn bitand_assign(&mut self, other: Matrix<R, M, N>)
&=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> BitAndAssign<R> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> BitAndAssign<R> for Matrix<L, M, N>
Source§fn bitand_assign(&mut self, r: R)
fn bitand_assign(&mut self, r: R)
&=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> BitOrAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> BitOrAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn bitor_assign(&mut self, other: &Matrix<R, M, N>)
fn bitor_assign(&mut self, other: &Matrix<R, M, N>)
|=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> BitOrAssign<Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> BitOrAssign<Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn bitor_assign(&mut self, other: Matrix<R, M, N>)
fn bitor_assign(&mut self, other: Matrix<R, M, N>)
|=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> BitOrAssign<R> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> BitOrAssign<R> for Matrix<L, M, N>
Source§fn bitor_assign(&mut self, r: R)
fn bitor_assign(&mut self, r: R)
|=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> BitXorAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> BitXorAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn bitxor_assign(&mut self, other: &Matrix<R, M, N>)
fn bitxor_assign(&mut self, other: &Matrix<R, M, N>)
^=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> BitXorAssign<Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> BitXorAssign<Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn bitxor_assign(&mut self, other: Matrix<R, M, N>)
fn bitxor_assign(&mut self, other: Matrix<R, M, N>)
^=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> BitXorAssign<R> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> BitXorAssign<R> for Matrix<L, M, N>
Source§fn bitxor_assign(&mut self, r: R)
fn bitxor_assign(&mut self, r: R)
^=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> DivAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> DivAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn div_assign(&mut self, other: &Matrix<R, M, N>)
fn div_assign(&mut self, other: &Matrix<R, M, N>)
/=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> DivAssign<Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> DivAssign<Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn div_assign(&mut self, other: Matrix<R, M, N>)
fn div_assign(&mut self, other: Matrix<R, M, N>)
/=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> DivAssign<R> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> DivAssign<R> for Matrix<L, M, N>
Source§fn div_assign(&mut self, r: R)
fn div_assign(&mut self, r: R)
/=
operation. Read moreSource§impl<T: Copy, const M: usize, const N: usize> FromIterator<T> for Matrix<T, M, N>where
Self: Default,
impl<T: Copy, const M: usize, const N: usize> FromIterator<T> for Matrix<T, M, N>where
Self: Default,
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Source§impl<I, T, const M: usize, const N: usize> Index<I> for Matrix<T, M, N>where
I: MatrixIndex,
T: Copy,
impl<I, T, const M: usize, const N: usize> Index<I> for Matrix<T, M, N>where
I: MatrixIndex,
T: Copy,
Source§impl<I, T, const M: usize, const N: usize> IndexMut<I> for Matrix<T, M, N>where
I: MatrixIndex,
T: Copy,
impl<I, T, const M: usize, const N: usize> IndexMut<I> for Matrix<T, M, N>where
I: MatrixIndex,
T: Copy,
Source§impl<T: Copy + Inv<Output = T> + Default, const M: usize, const N: usize> Inv for Matrix<T, M, N>
Inverse trait. Note that this is the elementwise inverse, not the matrix inverse.
For the inverse matrix see LUDecomposable::inv()
impl<T: Copy + Inv<Output = T> + Default, const M: usize, const N: usize> Inv for Matrix<T, M, N>
Inverse trait. Note that this is the elementwise inverse, not the matrix inverse.
For the inverse matrix see LUDecomposable::inv()
Source§impl<T, const N: usize> LUDecompose<T, N> for Matrix<T, N, N>
impl<T, const N: usize> LUDecompose<T, N> for Matrix<T, N, N>
Source§fn lu(&self) -> Option<LUDecomposition<T, N>>
fn lu(&self) -> Option<LUDecomposition<T, N>>
LUDecomposition
, or None
if the matrix is singular.
This can be used to solve for multiple results Read moreSource§impl<L, R, const M: usize, const N: usize> MulAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> MulAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn mul_assign(&mut self, other: &Matrix<R, M, N>)
fn mul_assign(&mut self, other: &Matrix<R, M, N>)
*=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> MulAssign<Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> MulAssign<Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn mul_assign(&mut self, other: Matrix<R, M, N>)
fn mul_assign(&mut self, other: Matrix<R, M, N>)
*=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> MulAssign<R> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> MulAssign<R> for Matrix<L, M, N>
Source§fn mul_assign(&mut self, r: R)
fn mul_assign(&mut self, r: R)
*=
operation. Read moreSource§impl<T, R, O, const M: usize, const N: usize> Pow<Matrix<R, M, N>> for Matrix<T, M, N>
Pow for $Matrix^{Matrix}$
impl<T, R, O, const M: usize, const N: usize> Pow<Matrix<R, M, N>> for Matrix<T, M, N>
Pow for $Matrix^{Matrix}$
Source§impl<T, R, O, const M: usize, const N: usize> Pow<R> for Matrix<T, M, N>
Pow for $Matrix^{scalar}$
impl<T, R, O, const M: usize, const N: usize> Pow<R> for Matrix<T, M, N>
Pow for $Matrix^{scalar}$
Source§impl<L, R, const M: usize, const N: usize> RemAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> RemAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn rem_assign(&mut self, other: &Matrix<R, M, N>)
fn rem_assign(&mut self, other: &Matrix<R, M, N>)
%=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> RemAssign<Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> RemAssign<Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn rem_assign(&mut self, other: Matrix<R, M, N>)
fn rem_assign(&mut self, other: Matrix<R, M, N>)
%=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> RemAssign<R> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> RemAssign<R> for Matrix<L, M, N>
Source§fn rem_assign(&mut self, r: R)
fn rem_assign(&mut self, r: R)
%=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> ShlAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> ShlAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn shl_assign(&mut self, other: &Matrix<R, M, N>)
fn shl_assign(&mut self, other: &Matrix<R, M, N>)
<<=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> ShlAssign<Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> ShlAssign<Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn shl_assign(&mut self, other: Matrix<R, M, N>)
fn shl_assign(&mut self, other: Matrix<R, M, N>)
<<=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> ShlAssign<R> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> ShlAssign<R> for Matrix<L, M, N>
Source§fn shl_assign(&mut self, r: R)
fn shl_assign(&mut self, r: R)
<<=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> ShrAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> ShrAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn shr_assign(&mut self, other: &Matrix<R, M, N>)
fn shr_assign(&mut self, other: &Matrix<R, M, N>)
>>=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> ShrAssign<Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> ShrAssign<Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn shr_assign(&mut self, other: Matrix<R, M, N>)
fn shr_assign(&mut self, other: Matrix<R, M, N>)
>>=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> ShrAssign<R> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> ShrAssign<R> for Matrix<L, M, N>
Source§fn shr_assign(&mut self, r: R)
fn shr_assign(&mut self, r: R)
>>=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> SubAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> SubAssign<&Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn sub_assign(&mut self, other: &Matrix<R, M, N>)
fn sub_assign(&mut self, other: &Matrix<R, M, N>)
-=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> SubAssign<Matrix<R, M, N>> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> SubAssign<Matrix<R, M, N>> for Matrix<L, M, N>
Source§fn sub_assign(&mut self, other: Matrix<R, M, N>)
fn sub_assign(&mut self, other: Matrix<R, M, N>)
-=
operation. Read moreSource§impl<L, R, const M: usize, const N: usize> SubAssign<R> for Matrix<L, M, N>
impl<L, R, const M: usize, const N: usize> SubAssign<R> for Matrix<L, M, N>
Source§fn sub_assign(&mut self, r: R)
fn sub_assign(&mut self, r: R)
-=
operation. Read moreimpl<T, const M: usize, const N: usize> Copy for Matrix<T, M, N>
impl<T, const M: usize, const N: usize> StructuralPartialEq for Matrix<T, M, N>where
T: Copy,
Auto Trait Implementations§
impl<T, const M: usize, const N: usize> Freeze for Matrix<T, M, N>where
T: Freeze,
impl<T, const M: usize, const N: usize> RefUnwindSafe for Matrix<T, M, N>where
T: RefUnwindSafe,
impl<T, const M: usize, const N: usize> Send for Matrix<T, M, N>where
T: Send,
impl<T, const M: usize, const N: usize> Sync for Matrix<T, M, N>where
T: Sync,
impl<T, const M: usize, const N: usize> Unpin for Matrix<T, M, N>where
T: Unpin,
impl<T, const M: usize, const N: usize> UnwindSafe for Matrix<T, M, N>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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