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
32
33
34
35
36
37
38
39
40
41
use std::{error::Error, fmt};

#[derive(Debug, Default, Clone, Hash, PartialEq, PartialOrd, Eq, Ord)]
pub struct ErrorGeneric {
    b: u32,
}

impl ErrorGeneric {
    pub fn new(b: u32) -> Self {
        Self {
            b,
        }
    }
}

impl fmt::Display for ErrorGeneric {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(
            f,
            "parser.ErrorGeneric: expected=(4 <= b <= 16), got b=({:?})",
            self.b
        )
    }
}

impl Error for ErrorGeneric {}

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }

    use pretty_assertions::assert_eq;

    #[test]
    fn it_works_pretty_assertions() {
        assert_eq!(2 + 2, 4);
    }
}