Skip to content

Commit 02dec3e

Browse files
committed
Implement AsRef instead of custom method
Clippy emits a warning since we define a method that has the same name as a standard trait. Implement the trait `AsRef` instead of using a custom method.
1 parent 3afc172 commit 02dec3e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

secp256k1-sys/src/macros.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ macro_rules! impl_array_newtype {
3434
dat.as_mut_ptr()
3535
}
3636

37-
#[inline]
38-
/// Gets a reference to the underlying array
39-
pub fn as_ref(&self) -> &[$ty; $len] {
40-
let &$thing(ref dat) = self;
41-
dat
42-
}
43-
4437
#[inline]
4538
/// Returns the length of the object as an array
4639
pub fn len(&self) -> usize { $len }
@@ -50,6 +43,15 @@ macro_rules! impl_array_newtype {
5043
pub fn is_empty(&self) -> bool { false }
5144
}
5245

46+
impl AsRef<[$ty; $len]> for $thing {
47+
#[inline]
48+
/// Gets a reference to the underlying array
49+
fn as_ref(&self) -> &[$ty; $len] {
50+
let &$thing(ref dat) = self;
51+
dat
52+
}
53+
}
54+
5355
impl PartialEq for $thing {
5456
#[inline]
5557
fn eq(&self, other: &$thing) -> bool {

0 commit comments

Comments
 (0)