use super::*;
use ::std::error::Error;
#[derive(Clone, Copy, Debug)]
pub struct OutOfCapacityError<T>(pub T);
impl<T> fmt::Display for OutOfCapacityError<T> {
fn fmt (
self: &Self,
stream: &mut fmt::Formatter,
) -> fmt::Result
{
fmt::Display::fmt(
"Attempted to add an element to a full StackVec",
stream
)
}
}
impl<T: fmt::Debug> ::std::error::Error for OutOfCapacityError<T> {
fn description (
self: &Self,
) -> &str
{
"Attempted to add an element to a full StackVec"
}
}
#[derive(Clone, Copy, Debug)]
pub struct IncompleteArrayError;
impl fmt::Display for IncompleteArrayError {
fn fmt (
self: &Self,
stream: &mut fmt::Formatter,
) -> fmt::Result
{
fmt::Display::fmt(self.description(), stream)
}
}
impl ::std::error::Error for IncompleteArrayError {
fn description (
self: &Self,
) -> &str
{
concat!(
"Cannot build an incomplete array.",
)
}
}
#[derive(Debug)]
pub enum UnreachableError {}
impl UnreachableError {
pub fn unreachable (&self) -> ! { match *self {} }
}
impl fmt::Display for UnreachableError {
fn fmt (&self, _: &mut fmt::Formatter) -> fmt::Result {
self.unreachable()
}
}
impl ::std::error::Error for UnreachableError {
fn description (&self) -> &str {
self.unreachable()
}
}