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