Croissant Runtime
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
crsn/asm/src/patches/try_remove.rs

17 lines
334 B

pub trait TryRemove {
type Item;
fn try_remove(&mut self, index: usize) -> Option<Self::Item>;
}
impl<T> TryRemove for Vec<T> {
type Item = T;
fn try_remove(&mut self, index: usize) -> Option<T> {
if self.is_empty() {
None
} else {
Some(self.remove(index))
}
}
}