pub trait SplitTail: VecLike + Sized {
// Required method
fn split_tail(
&mut self,
mid: usize,
) -> (&mut [Self::T], TailVec<'_, Self::T, Self>);
}Expand description
Split at index, tail part is TailVec
Required Methods§
Sourcefn split_tail(
&mut self,
mid: usize,
) -> (&mut [Self::T], TailVec<'_, Self::T, Self>)
fn split_tail( &mut self, mid: usize, ) -> (&mut [Self::T], TailVec<'_, Self::T, Self>)
Split at index, tail part is TailVec
§Panics
midgreater thanlen
§Leaking
If the returned TailVec goes out of scope without being dropped
(due to mem::forget, for example),
the Self may have lost and leaked elements arbitrarily,
including elements outside the range.
§Examples
let mut vec = vec![1, 2, 3];
let (left, mut rest) = vec.split_tail(2);
assert_eq!(left, &mut [1, 2]);
assert_eq!(rest, &mut [3]);
rest.pop().unwrap();
assert_eq!(rest, &mut []);
assert_eq!(rest.pop(), None);
assert_eq!(rest, &mut []);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.