1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::error::Error;
use std::fmt;

/**
 * An error indicating failure to convert a matrix to a scalar because it is not a unit matrix.
 */
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ScalarConversionError;

impl Error for ScalarConversionError {}

impl fmt::Display for ScalarConversionError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(
            f,
            "Matrix cannot be converted to a scalar because it is not 1x1"
        )
    }
}

#[test]
fn test_sync() {
    fn assert_sync<T: Sync>() {}
    assert_sync::<ScalarConversionError>();
}

#[test]
fn test_send() {
    fn assert_send<T: Send>() {}
    assert_send::<ScalarConversionError>();
}