use std::fmt::{Display, Formatter}; #[derive(Debug)] pub struct Error { message: String, } impl Error { pub fn new(message: impl AsRef) -> Self { Self { message: message.as_ref().to_string(), } } } impl Display for Error { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!("{}", self.message))?; Ok(()) } } impl std::error::Error for Error {}