wiwi/
slice.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
extern crate std;

pub use std::marker::Sized;
pub use std::slice::*;

#[inline]
pub fn unsize<T>(val: &T) -> &T::Unsized
where
	T: Unsize
{
	val.unsize()
}

pub trait Unsize {
	type Unsized: ?Sized;

	fn unsize(&self) -> &Self::Unsized;
	fn unsize_mut(&mut self) -> &mut Self::Unsized;
}

impl<T, const N: usize> Unsize for [T; N] {
	type Unsized = [T];

	#[inline]
	fn unsize(&self) -> &[T] {
		self
	}

	#[inline]
	fn unsize_mut(&mut self) -> &mut [T] {
		self
	}
}