use core::fmt::Display;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(PartialEq, Eq, Debug)]
pub enum Error {
InvalidQuantum,
AllocatorError,
Empty,
NoSuchAllocation,
NoSource,
WrappingSpan,
UnalignedSpan,
AllocZeroSize,
Other(&'static str),
}
impl Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::InvalidQuantum => write!(f, "the specified quantum was not a power of two"),
Self::AllocatorError => write!(f, "the allocator returned an error"),
Self::Empty => write!(f, "empty"),
Self::NoSuchAllocation => write!(f, "no such allocation"),
Self::NoSource => write!(f, "no source"),
Self::WrappingSpan => write!(f, "invalid span"),
Self::UnalignedSpan => write!(f, "this span would wrap around the address space"),
Self::AllocZeroSize => write!(f, "attempted to allocate a zero-sized block"),
Self::Other(s) => write!(f, "{}", s),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for Error {}