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.
This commit is contained in:
Tobin Harding 2020-12-22 11:47:22 +11:00
parent 3afc172096
commit 02dec3eb9b
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 9 additions and 7 deletions

View File

@ -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 {