From 9850550734af82b31523c8d9d73190d14ab63fda Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 18 Nov 2022 10:57:32 +1100 Subject: [PATCH] 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. --- secp256k1-sys/src/macros.rs | 18 +++++++++--------- src/macros.rs | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/secp256k1-sys/src/macros.rs b/secp256k1-sys/src/macros.rs index 98499ff76..35734fcce 100644 --- a/secp256k1-sys/src/macros.rs +++ b/secp256k1-sys/src/macros.rs @@ -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`. #[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 core::ops::Index for $thing where [$ty]: core::ops::Index, diff --git a/src/macros.rs b/src/macros.rs index 1ed2bd135..e89e8d07d 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -18,15 +18,6 @@ macro_rules! impl_array_newtype { ($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`. 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 core::ops::Index for $thing where [$ty]: core::ops::Index,