From e8ed11476c56658530c17f6585c9613376a5ac40 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 30 Dec 2023 19:39:12 -0700 Subject: [PATCH] hybrid-array: add `Borrow(Mut)` bounds to `SliceOps` (#1022) --- hybrid-array/src/lib.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hybrid-array/src/lib.rs b/hybrid-array/src/lib.rs index a912e925..5ed07abf 100644 --- a/hybrid-array/src/lib.rs +++ b/hybrid-array/src/lib.rs @@ -250,6 +250,16 @@ where } } +impl Borrow<[T]> for Array +where + U: ArraySize, +{ + #[inline] + fn borrow(&self) -> &[T] { + self.0.as_ref() + } +} + impl Borrow<[T; N]> for Array where Self: ArrayOps, @@ -261,6 +271,16 @@ where } } +impl BorrowMut<[T]> for Array +where + U: ArraySize, +{ + #[inline] + fn borrow_mut(&mut self) -> &mut [T] { + self.0.as_mut() + } +} + impl BorrowMut<[T; N]> for Array where Self: ArrayOps, @@ -633,6 +653,8 @@ impl ArrayOps for [T; N] { pub trait SliceOps: AsRef<[T]> + AsMut<[T]> + + Borrow<[T]> + + BorrowMut<[T]> + Index + Index> + IndexMut