custom_string/
validation_error.rs1#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
3pub struct ValidationError {
4 message: &'static str,
5}
6
7impl ValidationError {
8 pub fn new(message: &'static str) -> Self {
12 Self { message }
13 }
14
15 pub fn message(&self) -> &'static str {
17 self.message
18 }
19}
20
21impl std::fmt::Display for ValidationError {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 write!(f, "{}", self.message)
24 }
25}
26
27impl std::error::Error for ValidationError {}