Skip to content

Commit 37c1560

Browse files
authored
hybrid-array: re-add AsRef<[T; N]>/AsMut<[T; N]> impls (#1031)
These were removed in #1026 for more consistency with core arrays. However, `generic-array` provides these impls, which makes removing them problematic when migrating `generic-array`-based code, so it's easier to keep them around, even if it breaks inference due to overlapping impls.
1 parent c37259c commit 37c1560

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

hybrid-array/src/lib.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,17 @@ where
212212
}
213213
}
214214

215+
impl<T, U, const N: usize> AsRef<[T; N]> for Array<T, U>
216+
where
217+
Self: ArrayOps<T, N>,
218+
U: ArraySize,
219+
{
220+
#[inline]
221+
fn as_ref(&self) -> &[T; N] {
222+
self.as_core_array()
223+
}
224+
}
225+
215226
impl<T, U> AsMut<[T]> for Array<T, U>
216227
where
217228
U: ArraySize,
@@ -222,6 +233,17 @@ where
222233
}
223234
}
224235

236+
impl<T, U, const N: usize> AsMut<[T; N]> for Array<T, U>
237+
where
238+
Self: ArrayOps<T, N>,
239+
U: ArraySize,
240+
{
241+
#[inline]
242+
fn as_mut(&mut self) -> &mut [T; N] {
243+
self.as_mut_core_array()
244+
}
245+
}
246+
225247
impl<T, U> Borrow<[T]> for Array<T, U>
226248
where
227249
U: ArraySize,

0 commit comments

Comments
 (0)