use std::fmt;
use crate::Status;
pub trait Kind: Copy + Clone + fmt::Display + fmt::Debug + Send + Sync + 'static {
fn into_status<C: crate::Context>(self) -> Status<Self, C> {
Status::new(self)
}
fn into_err<T, C: crate::Context>(self) -> Result<T, Status<Self, C>> {
Err(Status::new(self))
}
}
impl<U> Kind for U where U: Copy + Clone + fmt::Display + fmt::Debug + Send + Sync + 'static {}
#[derive(Copy, Clone, Debug)]
pub struct Unkind {
inner: &'static str,
}
impl From<&'static str> for Unkind {
fn from(s: &'static str) -> Self {
Self { inner: s }
}
}
impl fmt::Display for Unkind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "{}", self.inner)
}
}
#[cfg(test)]
mod test {
use super::*;
use static_assertions::*;
#[test]
fn unkind() {
assert_impl_all!(Unkind: Kind);
}
}