pub const fn get_from<T>(slice: &[T], start: usize) -> Option<&[T]>
Expand description
A const equivalent of slice.get(start..)
.
ยงExample
use konst::slice;
const FIBB: &[u16] = &[3, 5, 8, 13, 21, 34, 55, 89];
const TWO: Option<&[u16]> = slice::get_from(FIBB, 2);
const FOUR: Option<&[u16]> = slice::get_from(FIBB, 4);
const ALL: Option<&[u16]> = slice::get_from(FIBB, 0);
const NONE: Option<&[u16]> = slice::get_from(FIBB, 1000);
assert_eq!(TWO, Some(&[8, 13, 21, 34, 55, 89][..]));
assert_eq!(FOUR, Some(&[21, 34, 55, 89][..]));
assert_eq!(ALL, Some(FIBB));
assert_eq!(NONE, None);