Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit 688c862

Browse files
committed
Remove implementation of Deref
According to the Rust docs [0] on the `Deref` trait, it should only be implemented for smart pointers. Remove the implementation of `Deref`. [0] https://doc.rust-lang.org/std/ops/trait.Deref.html
1 parent 180c6fb commit 688c862

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/util.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ macro_rules! hex_fmt_impl(
2828
write!(f, "0x")?;
2929
}
3030
if $ty::<$($gen),*>::DISPLAY_BACKWARD {
31-
hex::format_hex_reverse(&self.0, f)
31+
hex::format_hex_reverse(self.as_ref(), f)
3232
} else {
33-
hex::format_hex(&self.0, f)
33+
hex::format_hex(self.as_ref(), f)
3434
}
3535
}
3636
}
@@ -67,14 +67,6 @@ macro_rules! borrow_slice_impl(
6767
&self[..]
6868
}
6969
}
70-
71-
impl<$($gen: $gent),*> $crate::_export::_core::ops::Deref for $ty<$($gen),*> {
72-
type Target = [u8];
73-
74-
fn deref(&self) -> &Self::Target {
75-
&self.0
76-
}
77-
}
7870
)
7971
);
8072

@@ -243,7 +235,7 @@ mod test {
243235
fn borrow_slice_impl_to_vec() {
244236
// Test that the borrow_slice_impl macro gives to_vec.
245237
let hash = sha256::Hash::hash(&[3, 50]);
246-
assert_eq!(hash.to_vec().len(), sha256::Hash::LEN);
238+
assert_eq!(hash.as_ref().len(), sha256::Hash::LEN);
247239
}
248240

249241
hash_newtype!(TestHash, crate::sha256d::Hash, 32, doc="Test hash.");

0 commit comments

Comments
 (0)