slice_trait
A trait for any slice, with item as an associated type.
This crate is a subset of the crate slice_ops.
Example
use *;
let a: & = .as_slice;
Sized> where
Item: Copy,
assert_eq!;
A trait for any slice, with item as an associated type.
This crate is a subset of the crate slice_ops.
use slice_trait::*;
let a: &[i32] = [1, 2, 3].as_slice();
fn first<'a, S: Slice + ?Sized>(slice: &'a S) -> Option<&'a S::Item>
where
S::Item: Copy,
{
slice.as_slice().first()
}
assert_eq!(first(a), Some(&1));