| 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 | fn from(_: PushError<T>) -> Error {
|
| 19 | |
| 20 | |
| 21 | EINVAL
|
| 22 | }
|
| 23 | }
|
| 24 |
|
| 25 | |
| 26 | pub struct RemoveError;
|
| 27 |
|
| 28 | impl fmt::Debug for RemoveError {
|
| 29 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
| 30 | write!(f, "Index out of bounds")
|
| 31 | }
|
| 32 | }
|
| 33 |
|
| 34 | impl From<RemoveError> for Error {
|
| 35 | fn from(_: RemoveError) -> Error {
|
| 36 | EINVAL
|
| 37 | }
|
| 38 | }
|
| 39 |
|
| 40 | |
| 41 | pub enum InsertError<T> {
|
| 42 | |
| 43 | IndexOutOfBounds(T),
|
| 44 | |
| 45 | OutOfCapacity(T),
|
| 46 | }
|
| 47 |
|
| 48 | impl<T> fmt::Debug for InsertError<T> {
|
| 49 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
| 50 | match self {
|
| 51 | InsertError::IndexOutOfBounds(_) => write!(f, "Index out of bounds"),
|
| 52 | InsertError::OutOfCapacity(_) => write!(f, "Not enough capacity"),
|
| 53 | }
|
| 54 | }
|
| 55 | }
|
| 56 |
|
| 57 | impl<T> From<InsertError<T>> for Error {
|
| 58 | fn from(_: InsertError<T>) -> Error {
|
| 59 | EINVAL
|
| 60 | }
|
| 61 | }
|