wiwi_util/
slice.rs

1pub use std::marker::Sized;
2pub use std::slice::*;
3
4#[inline]
5pub fn unsize<T>(val: &T) -> &T::Unsized
6where
7	T: Unsize
8{
9	val.unsize()
10}
11
12pub trait Unsize {
13	type Unsized: ?Sized;
14
15	fn unsize(&self) -> &Self::Unsized;
16	fn unsize_mut(&mut self) -> &mut Self::Unsized;
17}
18
19impl<T, const N: usize> Unsize for [T; N] {
20	type Unsized = [T];
21
22	#[inline]
23	fn unsize(&self) -> &[T] {
24		self
25	}
26
27	#[inline]
28	fn unsize_mut(&mut self) -> &mut [T] {
29		self
30	}
31}