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.
Some member functions that could be added to Vec:
This is similar to
Vec::removebut likeVec::popit returns anOption, avoiding panics:(In alternative
Vec::pop_frontcould often suffice).Probably this was already suggested elsewhere:
They contain a
debug_assert!()to test the bounds only in debug builds. I think suchdebug_assertcan't be added toget_unchecked/get_unchecked_mutbecause the semantics is different. They are unsafe, but they add a bit of safety during debug runs.