Make push and push_str return Results

The error type is called `CapacityError` and lets you extract the pushed
element.
This commit is contained in:
Tobias Bucher
2015-09-13 12:52:16 +01:00
parent 10aa8245d8
commit 6a8fdfdedb
2 changed files with 32 additions and 26 deletions
+15
View File
@@ -36,6 +36,21 @@ unsafe fn new_array<A: Array>() -> A {
mem::uninitialized()
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct CapacityError<T> {
_unused: (),
pub element: T,
}
impl<T> CapacityError<T> {
fn new(element: T) -> CapacityError<T> {
CapacityError {
_unused: (),
element: element,
}
}
}
/// A vector with a fixed capacity.
///
/// The `ArrayVec` is a vector backed by a fixed size array. It keeps track of