Skip to content

Commit 9850550

Browse files
committed
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.
1 parent 4d42e8e commit 9850550

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

secp256k1-sys/src/macros.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@ macro_rules! impl_array_newtype {
4545
}
4646
}
4747

48-
impl AsRef<[$ty; $len]> for $thing {
49-
#[inline]
50-
/// Gets a reference to the underlying array
51-
fn as_ref(&self) -> &[$ty; $len] {
52-
let &$thing(ref dat) = self;
53-
dat
54-
}
55-
}
56-
5748
// We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`.
5849

5950
#[cfg(fuzzing)]
@@ -90,6 +81,15 @@ macro_rules! impl_array_newtype {
9081
}
9182
}
9283

84+
impl AsRef<[$ty; $len]> for $thing {
85+
#[inline]
86+
/// Gets a reference to the underlying array
87+
fn as_ref(&self) -> &[$ty; $len] {
88+
let &$thing(ref dat) = self;
89+
dat
90+
}
91+
}
92+
9393
impl<I> core::ops::Index<I> for $thing
9494
where
9595
[$ty]: core::ops::Index<I>,

src/macros.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@
1818
macro_rules! impl_array_newtype {
1919
($thing:ident, $ty:ty, $len:expr) => {
2020

21-
impl AsRef<[$ty; $len]> for $thing {
22-
#[inline]
23-
/// Gets a reference to the underlying array
24-
fn as_ref(&self) -> &[$ty; $len] {
25-
let &$thing(ref dat) = self;
26-
dat
27-
}
28-
}
29-
3021
// We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`.
3122

3223
impl PartialEq for $thing {
@@ -58,6 +49,15 @@ macro_rules! impl_array_newtype {
5849
}
5950
}
6051

52+
impl AsRef<[$ty; $len]> for $thing {
53+
#[inline]
54+
/// Gets a reference to the underlying array
55+
fn as_ref(&self) -> &[$ty; $len] {
56+
let &$thing(ref dat) = self;
57+
dat
58+
}
59+
}
60+
6161
impl<I> core::ops::Index<I> for $thing
6262
where
6363
[$ty]: core::ops::Index<I>,

0 commit comments

Comments
 (0)