easy_ml/matrices/
errors.rs

1use std::error::Error;
2use std::fmt;
3
4/**
5 * An error indicating failure to convert a matrix to a scalar because it is not a unit matrix.
6 */
7#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8pub struct ScalarConversionError;
9
10impl Error for ScalarConversionError {}
11
12impl fmt::Display for ScalarConversionError {
13    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14        write!(
15            f,
16            "Matrix cannot be converted to a scalar because it is not 1x1"
17        )
18    }
19}
20
21#[test]
22fn test_sync() {
23    fn assert_sync<T: Sync>() {}
24    assert_sync::<ScalarConversionError>();
25}
26
27#[test]
28fn test_send() {
29    fn assert_send<T: Send>() {}
30    assert_send::<ScalarConversionError>();
31}