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:
parent
3afc172096
commit
02dec3eb9b
|
@ -34,13 +34,6 @@ macro_rules! impl_array_newtype {
|
||||||
dat.as_mut_ptr()
|
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]
|
#[inline]
|
||||||
/// Returns the length of the object as an array
|
/// Returns the length of the object as an array
|
||||||
pub fn len(&self) -> usize { $len }
|
pub fn len(&self) -> usize { $len }
|
||||||
|
@ -50,6 +43,15 @@ macro_rules! impl_array_newtype {
|
||||||
pub fn is_empty(&self) -> bool { false }
|
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 {
|
impl PartialEq for $thing {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &$thing) -> bool {
|
fn eq(&self, other: &$thing) -> bool {
|
||||||
|
|
Loading…
Reference in New Issue