1use std::fmt::{self, Display};
2
3#[derive(Debug)]
9pub struct Error {
10 message: String,
11}
12
13pub type Result<T> = std::result::Result<T, Error>;
19
20impl Error {
21 pub fn new<T: Display>(message: T) -> Self {
22 Error {
23 message: message.to_string(),
24 }
25 }
26}
27
28impl std::error::Error for Error {}
29
30impl Display for Error {
31 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
32 formatter.write_str(&self.message)
33 }
34}
35
36#[doc(hidden)]
37#[allow(non_snake_case)]
38pub fn Error<T: Display>(message: T) -> Error {
39 Error::new(message)
40}