pub const fn first<T>(slice: &[T]) -> Option<&T>
Expand description
A const equivalent of
<[T]>::first
ยงExample
use konst::slice;
assert_eq!(slice::first(&[8, 5, 3]), Some(&8));
assert_eq!(slice::first(&[5, 3]), Some(&5));
assert_eq!(slice::first(&[3]), Some(&3));
assert_eq!(slice::first::<u8>(&[]), None);