pub trait View
{
type View<'a>: View where Self: 'a;
fn as_view<'a>(&'a self) -> Self::View<'a>;
}
impl<T> View for [T] {
type View<'a> = &'a [T] where Self: 'a;
fn as_view<'a>(&'a self) -> Self::View<'a> { self }
}
impl<T> View for &[T] {
type View<'a> = &'a [T] where Self: 'a;
fn as_view<'a>(&'a self) -> Self::View<'a> { self }
}
impl<T> View for &mut [T] {
type View<'a> = &'a [T] where Self: 'a;
fn as_view<'a>(&'a self) -> Self::View<'a> { self }
}
impl<T> View for Vec<T> {
type View<'a> = &'a [T] where Self: 'a;
fn as_view<'a>(&'a self) -> Self::View<'a> { self }
}
impl<T, const N: usize> View for [T; N] {
type View<'a> = &'a [T] where Self: 'a;
fn as_view<'a>(&'a self) -> Self::View<'a> { self }
}
impl<T: View> View for &T {
type View<'a> = T::View<'a> where Self: 'a;
fn as_view<'a>(&'a self) -> Self::View<'a> { (*self).as_view() }
}
impl<T: View> View for &mut T {
type View<'a> = T::View<'a> where Self: 'a;
fn as_view<'a>(&'a self) -> Self::View<'a> { (**self).as_view() }
}