use crate::std_facade::{fmt, Cow, String, Box};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Reason(Cow<'static, str>);
impl Reason {
pub fn message(&self) -> &str {
&*self.0
}
}
impl From<&'static str> for Reason {
fn from(s: &'static str) -> Self {
Reason(s.into())
}
}
impl From<String> for Reason {
fn from(s: String) -> Self {
Reason(s.into())
}
}
impl From<Box<str>> for Reason {
fn from(s: Box<str>) -> Self {
Reason(String::from(s).into())
}
}
impl fmt::Display for Reason {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(self.message(), f)
}
}