arraydeque/
error.rs

1#[cfg(feature = "std")]
2use std::error::Error;
3use std::fmt;
4
5/// Error value indicating insufficient capacity
6///
7/// This error only occur to `ArrayDeque<_, Saturating>`.
8#[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
9pub struct CapacityError<T = ()> {
10    /// The element that caused the error.
11    pub element: T,
12}
13
14const CAPERROR: &str = "insufficient capacity";
15
16#[cfg(feature = "std")]
17impl<T> Error for CapacityError<T> {}
18
19impl<T> fmt::Display for CapacityError<T> {
20    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21        f.write_str(CAPERROR)
22    }
23}
24
25impl<T> fmt::Debug for CapacityError<T> {
26    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
27        write!(f, "CapacityError: {}", CAPERROR)
28    }
29}