Don't allocate it IndexVec::remove

This commit is contained in:
Maybe Waffle 2023-04-17 13:37:03 +00:00
parent e1cd99f6ff
commit bd1dfcebe3

View file

@ -460,7 +460,7 @@ impl<I: Idx, T> IndexVec<I, Option<T>> {
#[inline]
pub fn remove(&mut self, index: I) -> Option<T> {
self.ensure_contains_elem(index, || None).take()
self.get_mut(index)?.take()
}
}