Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion hybrid-array/src/lib.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -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;
Expand DownExpand Up@@ -151,6 +151,26 @@ where
}
}

impl<T, U> Deref for Array<T, U>
where
U: ArraySize,
{
type Target = U::ArrayType<T>;

fn deref(&self) -> &U::ArrayType<T> {
&self.0
}
}

impl<T, U> DerefMut for Array<T, U>
where
U: ArraySize,
{
fn deref_mut(&mut self) -> &mut U::ArrayType<T> {
&mut self.0
}
}

impl<T, U, const N: usize> From<[T; N]> for Array<T, U>
where
Self: ArrayOps<T, N>,
Expand DownExpand Up@@ -273,6 +293,8 @@ pub trait ArrayOps<T, const N: usize>:
+ AsMut<[T; N]>
+ Borrow<[T; N]>
+ BorrowMut<[T; N]>
+ Deref<Target = [T; N]>
+ DerefMut
+ From<[T; N]>
+ Index<usize>
+ Index<Range<usize>>
Expand Down