Function konst::slice::get_range_mut [−][src]
pub const fn get_range_mut<T>(
slice: &mut [T],
start: usize,
end: usize
) -> Option<&mut [T]>
This is supported on crate features
mut_refs
or nightly_mut_refs
only.Expand description
A const equivalent of slice.get_mut(start..end)
.
Alternatives
For a const equivalent of slice.get_mut(start..)
there’s get_from_mut
.
For a const equivalent of slice.get_mut(..end)
there’s get_up_to_mut
.
Performance
If the “constant_time_slice” feature is disabled,
thich takes linear time to remove the leading and trailing elements,
proportional to start + (slice.len() - end)
.
If the “constant_time_slice” feature is enabled, it takes constant time to run, but uses a few nightly features.
Example
use konst::slice;
let mut fibb = [3, 5, 8, 13, 21, 34, 55];
assert_eq!(slice::get_range_mut(&mut fibb, 0, 0), Some(&mut [][..]));
assert_eq!(slice::get_range_mut(&mut fibb, 2, 4), Some(&mut [8, 13][..]));
assert_eq!(slice::get_range_mut(&mut fibb, 4, 7), Some(&mut [21, 34, 55][..]));
assert_eq!(slice::get_range_mut(&mut fibb, 0, 7), Some(&mut [3, 5, 8, 13, 21, 34, 55][..]));
assert_eq!(slice::get_range_mut(&mut fibb, 0, 1000), None);