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