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
use alloc::string::String;
use core::fmt::{self, Display, Formatter};
use serde::{Deserialize, Serialize};
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
pub struct TypeMismatch {
expected: String,
found: String,
}
impl TypeMismatch {
pub fn new(expected: String, found: String) -> TypeMismatch {
TypeMismatch { expected, found }
}
}
impl Display for TypeMismatch {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
write!(
formatter,
"Type mismatch. Expected {} but found {}.",
self.expected, self.found
)
}
}