Closed
Description
Some member functions that could be added to Vec:
This is similar to Vec::remove
but like Vec::pop
it returns an Option
, avoiding panics:
pub fn Vec::pop_index(&mut self, index: usize) -> Option<T>;
(In alternative Vec::pop_front
could often suffice).
Probably this was already suggested elsewhere:
pub unsafe fn get_debug<I>(&self, index: I) -> &<I as SliceIndex<[T]>>::Output;
pub unsafe fn get_debug_mut<I>(&mut self, index: I) -> &mut <I as SliceIndex<[T]>>::Output;
They contain a debug_assert!()
to test the bounds only in debug builds. I think such debug_assert
can't be added to get_unchecked
/get_unchecked_mut
because the semantics is different. They are unsafe, but they add a bit of safety during debug runs.
Metadata
Metadata
Assignees
Labels
No labels