use std::any::Any;
use std::error::Error;
use std::fmt;
use std::fmt::{Debug, Display, Formatter};
#[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
pub struct CapacityError<T = ()> {
element: T,
}
impl<T> CapacityError<T> {
pub const fn new(element: T) -> CapacityError<T> {
CapacityError { element }
}
pub fn element(self) -> T {
self.element
}
pub fn simplify(self) -> CapacityError {
CapacityError { element: () }
}
}
impl<T: Any> Error for CapacityError<T> {}
impl<T> Display for CapacityError<T> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "insufficient capacity")
}
}
impl<T> Debug for CapacityError<T> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "CapacityError: insufficient capacity")
}
}