Move AsRef impl block next to Index
These two traits are related, in as much as they both give access to the inner byte array. Put them next to each other to assist clarity.
This commit is contained in:
parent
4d42e8e906
commit
9850550734
|
@ -45,15 +45,6 @@ macro_rules! impl_array_newtype {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<[$ty; $len]> for $thing {
|
|
||||||
#[inline]
|
|
||||||
/// Gets a reference to the underlying array
|
|
||||||
fn as_ref(&self) -> &[$ty; $len] {
|
|
||||||
let &$thing(ref dat) = self;
|
|
||||||
dat
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`.
|
// We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`.
|
||||||
|
|
||||||
#[cfg(fuzzing)]
|
#[cfg(fuzzing)]
|
||||||
|
@ -90,6 +81,15 @@ macro_rules! impl_array_newtype {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsRef<[$ty; $len]> for $thing {
|
||||||
|
#[inline]
|
||||||
|
/// Gets a reference to the underlying array
|
||||||
|
fn as_ref(&self) -> &[$ty; $len] {
|
||||||
|
let &$thing(ref dat) = self;
|
||||||
|
dat
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<I> core::ops::Index<I> for $thing
|
impl<I> core::ops::Index<I> for $thing
|
||||||
where
|
where
|
||||||
[$ty]: core::ops::Index<I>,
|
[$ty]: core::ops::Index<I>,
|
||||||
|
|
|
@ -18,15 +18,6 @@
|
||||||
macro_rules! impl_array_newtype {
|
macro_rules! impl_array_newtype {
|
||||||
($thing:ident, $ty:ty, $len:expr) => {
|
($thing:ident, $ty:ty, $len:expr) => {
|
||||||
|
|
||||||
impl AsRef<[$ty; $len]> for $thing {
|
|
||||||
#[inline]
|
|
||||||
/// Gets a reference to the underlying array
|
|
||||||
fn as_ref(&self) -> &[$ty; $len] {
|
|
||||||
let &$thing(ref dat) = self;
|
|
||||||
dat
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`.
|
// We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`.
|
||||||
|
|
||||||
impl PartialEq for $thing {
|
impl PartialEq for $thing {
|
||||||
|
@ -58,6 +49,15 @@ macro_rules! impl_array_newtype {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsRef<[$ty; $len]> for $thing {
|
||||||
|
#[inline]
|
||||||
|
/// Gets a reference to the underlying array
|
||||||
|
fn as_ref(&self) -> &[$ty; $len] {
|
||||||
|
let &$thing(ref dat) = self;
|
||||||
|
dat
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<I> core::ops::Index<I> for $thing
|
impl<I> core::ops::Index<I> for $thing
|
||||||
where
|
where
|
||||||
[$ty]: core::ops::Index<I>,
|
[$ty]: core::ops::Index<I>,
|
||||||
|
|
Loading…
Reference in New Issue