matrix_basic/
errors.rs

1use std::{
2    error::Error,
3    fmt::{self, Display, Formatter},
4};
5
6/// Error type for using in this crate. Mostly to reduce writing
7/// error description every time.
8#[derive(Debug, PartialEq)]
9pub enum MatrixError {
10    /// Provided matrix isn't square.
11    NotSquare,
12    /// provided matrix is singular.
13    Singular,
14    /// Provided array has unequal rows.
15    UnequalRows,
16}
17
18impl Display for MatrixError {
19    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
20        let out = match *self {
21            Self::NotSquare => "provided matrix isn't square",
22            Self::Singular => "provided matrix is singular",
23            Self::UnequalRows => "provided array has unequal rows",
24        };
25        write!(f, "{out}")
26    }
27}
28
29impl Error for MatrixError {}