slice_trait 0.3.14

A generic trait for any slice, with item as a type parameter
Documentation
mod private
{
    pub const trait Same<T>: Sized
    {
        fn same(self) -> Result<T, Self>;
    }
    impl<T, U> const Same<T> for U
    {
        default fn same(self) -> Result<T, Self>
        {
            Err(self)
        }
    }
    impl<T> const Same<T> for T
    {
        fn same(self) -> Result<T, Self>
        {
            Ok(self)
        }
    }
}

pub const trait Same: Sized
{
    fn same<T>(self) -> Result<T, Self>;
}
impl<U> const Same for U
{
    fn same<T>(self) -> Result<T, Self>
    {
        private::Same::<T>::same(self)
    }
}