matrixes/
errors.rs

1#[derive(Debug, thiserror::Error, PartialEq, Eq)]
2pub enum SizingError {
3    #[error("Invalid number or size of rows: {0}")]
4    Row(usize),
5    #[error("Invalid number or size of columns: {0}")]
6    Column(usize),
7    #[error("Invalid number or size of rows ({0}) and columns ({1}).")]
8    Both(usize, usize),
9    #[error("Matrix is not square")]
10    NotSquare,
11}
12
13#[derive(Debug, thiserror::Error, PartialEq, Eq)]
14pub enum IndexError {
15    #[error("Row value out of bounds: {0}")]
16    Row(usize),
17    #[error("Column value out of bounds: {0}")]
18    Column(usize),
19    #[error("Row and column values out of bounds: ({0}, {1})")]
20    Both(usize, usize),
21}
22
23#[derive(Debug, thiserror::Error, PartialEq, Eq)]
24pub enum MinorError {
25    #[error("Matrix is not square")]
26    NotSquare,
27    #[error("Problem with bounds: {0}")]
28    BoundsError(#[from] IndexError),
29}
30
31#[derive(Debug, thiserror::Error, PartialEq, Eq)]
32pub enum InversionError {
33    #[error("Matrix was not square")]
34    NotSquare,
35    #[error("Matrix's determinant was 0")]
36    InvalidDeterminant,
37}