From 02dec3eb9b0d79fa570800f29968492a7d71242f Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 22 Dec 2020 11:47:22 +1100 Subject: [PATCH] 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. --- secp256k1-sys/src/macros.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/secp256k1-sys/src/macros.rs b/secp256k1-sys/src/macros.rs index 4a30c27..5ca0198 100644 --- a/secp256k1-sys/src/macros.rs +++ b/secp256k1-sys/src/macros.rs @@ -34,13 +34,6 @@ macro_rules! impl_array_newtype { dat.as_mut_ptr() } - #[inline] - /// Gets a reference to the underlying array - pub fn as_ref(&self) -> &[$ty; $len] { - let &$thing(ref dat) = self; - dat - } - #[inline] /// Returns the length of the object as an array pub fn len(&self) -> usize { $len } @@ -50,6 +43,15 @@ macro_rules! impl_array_newtype { pub fn is_empty(&self) -> bool { false } } + 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 PartialEq for $thing { #[inline] fn eq(&self, other: &$thing) -> bool {