Trait matrix_basic::MatrixInto
source · pub trait MatrixInto<T: ToMatrix> {
// Required method
fn matrix_into(self) -> Matrix<T>;
}
Expand description
Trait for conversion between matrices of different types.
It only has a matrix_into()
method.
This is needed since negative trait bound are not supported in stable Rust
yet, so we’ll have a conflict trying to implement From
.
I plan to change this to the default From trait as soon as some sort
of specialization system is implemented.
You can track this issue here.
Required Methods§
sourcefn matrix_into(self) -> Matrix<T>
fn matrix_into(self) -> Matrix<T>
Method for converting a matrix into a matrix of type Matrix<T>
.
Example
use matrix_basic::Matrix;
use matrix_basic::MatrixInto;
let a = Matrix::from(vec![vec![1, 2, 3], vec![0, 1, 2]]).unwrap();
let b = Matrix::from(vec![vec![1.0, 2.0, 3.0], vec![0.0, 1.0, 2.0]]).unwrap();
let c: Matrix<f64> = a.matrix_into(); // Type annotation is needed here
assert_eq!(c, b);
Implementors§
impl<T: ToMatrix, S: ToMatrix + Into<T>> MatrixInto<T> for Matrix<S>
Blanket implementation of MatrixInto
for converting Matrix<S>
to Matrix<T>
whenever
S
implements [Into(T)
]. Look at matrix_into
.