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
use alloc::string::String;
use core::fmt::{Display, Error, Formatter};
pub type PResult<T> = Result<T, PError>;
#[derive(Debug)]
pub enum PError {
Mismatch,
Terminate {
name: &'static str,
msg: String,
},
}
impl Display for PError {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
match self {
Self::Mismatch => write!(f, "not matched"),
Self::Terminate { name, msg } => {
write!(f, "invalid {}: \n\n{}", name, msg)
}
}
}
}