Function konst::slice::slice_from_mut [−][src]
pub const fn slice_from_mut<T>(slice: &mut [T], start: usize) -> &mut [T]
This is supported on crate features
mut_refs
or nightly_mut_refs
only.Expand description
A const equivalent of &mut slice[start..]
.
If slice.len() < start
, this simply returns an empty slice.
Performance
If the “constant_time_slice” feature is disabled,
thich takes linear time to remove the leading elements,
proportional to start
.
If the “constant_time_slice” feature is enabled, it takes constant time to run, but uses a few nightly features.
Example
use konst::slice::slice_from_mut;
let mut fibs = [3, 5, 8, 13, 21, 34, 55, 89];
assert_eq!(slice_from_mut(&mut fibs, 0), &mut [3, 5, 8, 13, 21, 34, 55, 89]);
assert_eq!(slice_from_mut(&mut fibs, 1), &mut [5, 8, 13, 21, 34, 55, 89]);
assert_eq!(slice_from_mut(&mut fibs, 2), &mut [8, 13, 21, 34, 55, 89]);
assert_eq!(slice_from_mut(&mut fibs, 6), &mut [55, 89]);
assert_eq!(slice_from_mut(&mut fibs, 7), &mut [89]);
assert_eq!(slice_from_mut(&mut fibs, 8), &mut []);
assert_eq!(slice_from_mut(&mut fibs, 1000), &mut []);