diff --git a/hybrid-array/src/lib.rs b/hybrid-array/src/lib.rs index c2c34732..36e439fb 100644 --- a/hybrid-array/src/lib.rs +++ b/hybrid-array/src/lib.rs @@ -28,7 +28,7 @@ pub use typenum; use core::{ array::{IntoIter, TryFromSliceError}, borrow::{Borrow, BorrowMut}, - ops::{Index, IndexMut, Range}, + ops::{Deref, DerefMut, Index, IndexMut, Range}, slice::{Iter, IterMut}, }; use typenum::Unsigned; @@ -151,6 +151,26 @@ where } } +impl Deref for Array +where + U: ArraySize, +{ + type Target = U::ArrayType; + + fn deref(&self) -> &U::ArrayType { + &self.0 + } +} + +impl DerefMut for Array +where + U: ArraySize, +{ + fn deref_mut(&mut self) -> &mut U::ArrayType { + &mut self.0 + } +} + impl From<[T; N]> for Array where Self: ArrayOps, @@ -273,6 +293,8 @@ pub trait ArrayOps: + AsMut<[T; N]> + Borrow<[T; N]> + BorrowMut<[T; N]> + + Deref + + DerefMut + From<[T; N]> + Index + Index>