mathrc 0.2.6

Rust Mathematics Library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::fmt;

#[derive(Debug, Clone, PartialEq)]
pub enum MatrixError {
    InvalidSize { expected: usize, got: usize },
    DimensionMismatch { lhs: (usize, usize), rhs: (usize, usize) },
}

impl fmt::Display for MatrixError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            MatrixError::InvalidSize { expected, got } =>
                write!(f, "invalid matrix size: expected {expected}, got {got}"),
            MatrixError::DimensionMismatch { lhs, rhs } =>
                write!(f, "dimension mismatch: ({} x {}) vs ({} x {})", lhs.0, lhs.1, rhs.0, rhs.1),
        }
    }
}