#![deny(missing_docs)]
#![deny(warnings)]
#![no_std]
extern crate stable_deref_trait;
pub trait AsSlice {
type Element;
fn as_slice(&self) -> &[Self::Element];
}
pub trait AsMutSlice: AsSlice {
fn as_mut_slice(&mut self) -> &mut [Self::Element];
}
impl<'a, S> AsSlice for &'a S
where
S: ?Sized + AsSlice,
{
type Element = S::Element;
fn as_slice(&self) -> &[S::Element] {
(**self).as_slice()
}
}
impl<'a, S> AsSlice for &'a mut S
where
S: ?Sized + AsSlice,
{
type Element = S::Element;
fn as_slice(&self) -> &[S::Element] {
(**self).as_slice()
}
}
impl<'a, S> AsMutSlice for &'a mut S
where
S: ?Sized + AsMutSlice,
{
fn as_mut_slice(&mut self) -> &mut [S::Element] {
(**self).as_mut_slice()
}
}
impl<T> AsSlice for [T] {
type Element = T;
fn as_slice(&self) -> &[T] {
self
}
}
impl<T> AsMutSlice for [T] {
fn as_mut_slice(&mut self) -> &mut [T] {
self
}
}
impl<T, const N: usize> AsSlice for [T; N] {
type Element = T;
fn as_slice(&self) -> &[T] {
self
}
}
impl<T, const N: usize> AsMutSlice for [T; N] {
fn as_mut_slice(&mut self) -> &mut [T] {
self
}
}