unsize cast array only on pointer type

This commit is contained in:
hkalbasi 2023-01-31 20:23:38 +03:30
parent 0fcef7fdd3
commit 0bf0d937b8
4 changed files with 43 additions and 18 deletions

View file

@ -273,6 +273,24 @@ pub mod ops {
}
}
impl<T, I, const N: usize> Index<I> for [T; N]
where
I: SliceIndex<[T]>,
{
type Output = I::Output;
fn index(&self, index: I) -> &I::Output {
loop {}
}
}
impl<T, I, const N: usize> IndexMut<I> for [T; N]
where
I: SliceIndex<[T]>,
{
fn index_mut(&mut self, index: I) -> &mut I::Output {
loop {}
}
}
pub unsafe trait SliceIndex<T: ?Sized> {
type Output: ?Sized;
}