use core::fmt;
pub type Result<T, E = core::convert::Infallible> = core::result::Result<T, E>;
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[non_exhaustive]
pub enum Error {
#[cfg(all(feature = "lock", not(feature = "parking-lot")))]
LockPoisoned,
#[cfg(any(not(feature = "lock"), feature = "parking-lot"))]
Infallible(core::convert::Infallible),
}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "{self:?}")
}
}
impl core::error::Error for Error {}
#[cfg(all(feature = "lock", not(feature = "parking-lot")))]
use crate::generator::{MutexGuard, PoisonError};
#[cfg(all(feature = "lock", not(feature = "parking-lot")))]
impl<T> From<PoisonError<MutexGuard<'_, T>>> for Error {
fn from(_: PoisonError<MutexGuard<'_, T>>) -> Self {
Self::LockPoisoned
}
}
#[cfg(any(not(feature = "lock"), feature = "parking-lot"))]
impl From<Error> for core::convert::Infallible {
fn from(e: Error) -> Self {
match e {
Error::Infallible(i) => i,
}
}
}