use core::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Error {
DomainError {
function: &'static str,
expected: &'static str,
},
}
impl Error {
#[must_use]
pub const fn domain(function: &'static str, expected: &'static str) -> Self {
Self::DomainError { function, expected }
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::DomainError { function, expected } => {
write!(
f,
"{function}: input outside valid domain, expected {expected}"
)
}
}
}
}
#[cfg(feature = "std")]
extern crate std;
#[cfg(feature = "std")]
impl std::error::Error for Error {}
pub type Result<T> = core::result::Result<T, Error>;