Function konst::slice::slice_from [−][src]
pub const fn slice_from<T>(slice: &[T], start: usize) -> &[T]
Expand description
A const equivalent of &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; const FIBB: &[u16] = &[3, 5, 8, 13, 21, 34, 55, 89]; const TWO: &[u16] = slice_from(FIBB, 2); const FOUR: &[u16] = slice_from(FIBB, 4); const ALL: &[u16] = slice_from(FIBB, 0); const NONE: &[u16] = slice_from(FIBB, 1000); assert_eq!(TWO, &[8, 13, 21, 34, 55, 89]); assert_eq!(FOUR, &[21, 34, 55, 89]); assert_eq!(ALL, FIBB); assert_eq!(NONE, &[]);