From 14b1e130a84e1a15967b6d17b9daec265794ed68 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Tue, 30 May 2023 18:02:02 -0600 Subject: [PATCH] hybrid-array: change `Deref::Target` to `[T]` (#913) This makes porting existing `generic-array` code easier, and also means deref coercion will allow `&Array` to deref to `&[T]`, making it usable anywhere a slice is. --- hybrid-array/src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hybrid-array/src/lib.rs b/hybrid-array/src/lib.rs index ef70b364..8c08cca0 100644 --- a/hybrid-array/src/lib.rs +++ b/hybrid-array/src/lib.rs @@ -183,10 +183,11 @@ impl Deref for Array where U: ArraySize, { - type Target = U::ArrayType; + type Target = [T]; - fn deref(&self) -> &U::ArrayType { - &self.0 + #[inline] + fn deref(&self) -> &[T] { + self.0.as_ref() } } @@ -194,8 +195,9 @@ impl DerefMut for Array where U: ArraySize, { - fn deref_mut(&mut self) -> &mut U::ArrayType { - &mut self.0 + #[inline] + fn deref_mut(&mut self) -> &mut [T] { + self.0.as_mut() } } @@ -320,8 +322,6 @@ pub trait ArrayOps: + AsMut<[T; N]> + Borrow<[T; N]> + BorrowMut<[T; N]> - + Deref - + DerefMut + From<[T; N]> + Index + Index>