Add method CapacityError::simplify
This is needed so that CapacityError<&str> isn't prohibitively difficult to use. It converts to CapacityError<()>.
This commit is contained in:
+6
-1
@@ -705,7 +705,7 @@ impl<A: Array<Item=u8>> io::Write for ArrayVec<A> {
|
|||||||
|
|
||||||
/// Error value indicating insufficient capacity
|
/// Error value indicating insufficient capacity
|
||||||
#[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
|
#[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
|
||||||
pub struct CapacityError<T> {
|
pub struct CapacityError<T = ()> {
|
||||||
element: T,
|
element: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -720,6 +720,11 @@ impl<T> CapacityError<T> {
|
|||||||
pub fn element(self) -> T {
|
pub fn element(self) -> T {
|
||||||
self.element
|
self.element
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert into a `CapacityError` that does not carry an element.
|
||||||
|
pub fn simplify(self) -> CapacityError {
|
||||||
|
CapacityError { element: () }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CAPERROR: &'static str = "insufficient capacity";
|
const CAPERROR: &'static str = "insufficient capacity";
|
||||||
|
|||||||
Reference in New Issue
Block a user