diff --git a/src/traits.rs b/src/traits.rs index 4ebe27d..336e731 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -59,3 +59,18 @@ impl<'a,T> Strided for MutStride<'a,T> { impl<'a,T> MutStrided for MutStride<'a,T> { fn as_stride_mut(&mut self) -> MutStride { self.reborrow() } } + +// this isn't as general as it could be. +impl<'a,T, X: Deref> From<&'a X> for Stride<'a,T> { + fn from(value: &X) -> Stride { Stride::new(&**value) } +} +impl<'a,T, X: DerefMut + Deref> From<&'a mut X> for MutStride<'a,T> { + fn from(value: &mut X) -> MutStride { MutStride::new(&mut **value) } +} + +impl<'a,T> From<&'a [T]> for Stride<'a,T> { + fn from(value: &[T]) -> Stride { Stride::new(value) } +} +impl<'a,T> From<&'a mut [T]> for MutStride<'a,T> { + fn from(value: &mut [T]) -> MutStride { MutStride::new(value) } +}