pub const fn get<T>(slice: &[T], index: usize) -> Option<&T>
Expand description
A const equivalent of slice.get(index)
ยงExample
use konst::slice;
const FIBB: &[u16] = &[3, 5, 8];
const ELEM0: Option<&u16> = slice::get(FIBB, 0);
const ELEM1: Option<&u16> = slice::get(FIBB, 1);
const ELEM2: Option<&u16> = slice::get(FIBB, 2);
const ELEM3: Option<&u16> = slice::get(FIBB, 3);
assert_eq!(ELEM0, Some(&3));
assert_eq!(ELEM1, Some(&5));
assert_eq!(ELEM2, Some(&8));
assert_eq!(ELEM3, None);