feat: add Into<> impls for ExactSlice and MinSlice
This commit is contained in:
parent
f6d43cd200
commit
ce4702c7b6
24
src/lib.rs
24
src/lib.rs
|
@ -215,6 +215,30 @@ impl<T, const N: usize> ExactSlice<T, N> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, T, const N: usize> Into<&'a MinSlice<T, N>> for &'a ExactSlice<T, N> {
|
||||
fn into(self) -> &'a MinSlice<T, N> {
|
||||
self.as_min_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, const N: usize> Into<&'a mut MinSlice<T, N>> for &'a mut ExactSlice<T, N> {
|
||||
fn into(self) -> &'a mut MinSlice<T, N> {
|
||||
self.as_mut_min_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, const N: usize> Into<&'a ExactSlice<T, N>> for &'a MinSlice<T, N> {
|
||||
fn into(self) -> &'a ExactSlice<T, N> {
|
||||
unsafe { ExactSlice::from_slice_unchecked(&self.head[..]) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, const N: usize> Into<&'a mut ExactSlice<T, N>> for &'a mut MinSlice<T, N> {
|
||||
fn into(self) -> &'a mut ExactSlice<T, N> {
|
||||
unsafe { ExactSlice::from_mut_unchecked(&mut self.head[..]) }
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn basic_min_success() {
|
||||
let slice = &[1, 2, 3, 4, 5, 6];
|
||||
|
|
Loading…
Reference in New Issue