Files
bdwgc-rust/src/error.rs
T
2023-05-21 02:35:25 +00:00

28 lines
483 B
Rust

use std::{
error,
fmt::{self, Display, Formatter},
};
#[derive(Debug)]
pub struct Error {
description: &'static str,
}
impl Error {
pub fn new(description: &'static str) -> Error {
Error { description }
}
}
impl Display for Error {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
write!(formatter, "{}", self.description)
}
}
impl error::Error for Error {
fn description(&self) -> &str {
self.description
}
}