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 convert_to() 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§

source

fn matrix_into(self) -> Matrix<T>

Method for converting a matrix into a matrix of type Matrix<T>

Implementors§

source§

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>.

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();

assert_eq!(c, b);