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
use std::{error::Error as StdError, fmt};
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum StringError {
FailedToString,
}
impl StdError for StringError {}
impl fmt::Display for StringError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
StringError::FailedToString => write!(f, "failed to convert value to string"),
}
}
}
#[cfg(test)]
mod tests {
use crate::errors::*;
#[test]
fn test_errors() {
assert_eq!(format!("{}", StringError::FailedToString), "failed to convert value to string");
}
}