FEAT: Turn try_remove/try_swap_remove into remove_opt and swap_pop

We turn these into "checked" removals, similar to `.pop()`. Name
swap_pop seems straightforward and nice, remove_opt is not as certain.
This commit is contained in:
bluss
2017-08-05 17:50:39 +02:00
parent bc9e0362bd
commit c5e0b80f73
2 changed files with 32 additions and 57 deletions
-36
View File
@@ -56,39 +56,3 @@ impl<T> fmt::Debug for CapacityError<T> {
}
}
pub struct OutOfBoundsError {
_priv: ()
}
impl PubCrateNew<()> for OutOfBoundsError {
fn new(_: ()) -> Self {
OutOfBoundsError { _priv: () }
}
}
impl OutOfBoundsError {
fn description(&self) -> &'static str {
"remove index is out of bounds"
}
}
#[cfg(feature="std")]
/// Requires `features="std"`.
impl Error for OutOfBoundsError {
fn description(&self) -> &str {
self.description()
}
}
impl fmt::Display for OutOfBoundsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl fmt::Debug for OutOfBoundsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "OutOfBoundsError: {}", self.description())
}
}