| 1 | |
| 2 |
|
| 3 | |
| 4 |
|
| 5 | use kernel::fmt;
|
| 6 | use kernel::prelude::*;
|
| 7 |
|
| 8 | |
| 9 | pub struct PushError<T>(pub T);
|
| 10 |
|
| 11 | impl<T> fmt::Debug for PushError<T> {
|
| 12 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
| 13 | write!(f, "Not enough capacity")
|
| 14 | }
|
| 15 | }
|
| 16 |
|
| 17 | impl<T> From<PushError<T>> for Error {
|
| 18 | #[inline]
|
| 19 | fn from(_: PushError<T>) -> Error {
|
| 20 | |
| 21 | |
| 22 | EINVAL
|
| 23 | }
|
| 24 | }
|
| 25 |
|
| 26 | |
| 27 | pub struct RemoveError;
|
| 28 |
|
| 29 | impl fmt::Debug for RemoveError {
|
| 30 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
| 31 | write!(f, "Index out of bounds")
|
| 32 | }
|
| 33 | }
|
| 34 |
|
| 35 | impl From<RemoveError> for Error {
|
| 36 | #[inline]
|
| 37 | fn from(_: RemoveError) -> Error {
|
| 38 | EINVAL
|
| 39 | }
|
| 40 | }
|
| 41 |
|
| 42 | |
| 43 | pub enum InsertError<T> {
|
| 44 | |
| 45 | IndexOutOfBounds(T),
|
| 46 | |
| 47 | OutOfCapacity(T),
|
| 48 | }
|
| 49 |
|
| 50 | impl<T> fmt::Debug for InsertError<T> {
|
| 51 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
| 52 | match self {
|
| 53 | InsertError::IndexOutOfBounds(_) => write!(f, "Index out of bounds"),
|
| 54 | InsertError::OutOfCapacity(_) => write!(f, "Not enough capacity"),
|
| 55 | }
|
| 56 | }
|
| 57 | }
|
| 58 |
|
| 59 | impl<T> From<InsertError<T>> for Error {
|
| 60 | #[inline]
|
| 61 | fn from(_: InsertError<T>) -> Error {
|
| 62 | EINVAL
|
| 63 | }
|
| 64 | }
|