custom_string/
validation_error.rs1#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, 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
16impl ValidationError {
17 pub fn message(self) -> &'static str {
21 self.message
22 }
23}
24
25impl std::fmt::Display for ValidationError {
26 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 write!(f, "{}", self.message)
28 }
29}
30
31impl std::error::Error for ValidationError {}