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

Commit

Permalink
Change Deref<Inner> impl for Hashes to Deref<[u8]>
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenroose committed Jul 6, 2019
1 parent a175a9e commit 7812a74
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/hash160.rs
Expand Up @@ -35,7 +35,7 @@ hex_fmt_impl!(Display, Hash);
hex_fmt_impl!(LowerHex, Hash);
index_impl!(Hash);
serde_impl!(Hash, 20);
borrow_slice_impl!(Hash, [u8; 20]);
borrow_slice_impl!(Hash);

impl str::FromStr for Hash {
type Err = Error;
Expand Down
2 changes: 1 addition & 1 deletion src/ripemd160.rs
Expand Up @@ -76,7 +76,7 @@ hex_fmt_impl!(Display, Hash);
hex_fmt_impl!(LowerHex, Hash);
index_impl!(Hash);
serde_impl!(Hash, 20);
borrow_slice_impl!(Hash, [u8; 20]);
borrow_slice_impl!(Hash);

impl str::FromStr for Hash {
type Err = Error;
Expand Down
2 changes: 1 addition & 1 deletion src/sha1.rs
Expand Up @@ -63,7 +63,7 @@ hex_fmt_impl!(Display, Hash);
hex_fmt_impl!(LowerHex, Hash);
index_impl!(Hash);
serde_impl!(Hash, 20);
borrow_slice_impl!(Hash, [u8; 20]);
borrow_slice_impl!(Hash);

impl str::FromStr for Hash {
type Err = Error;
Expand Down
4 changes: 2 additions & 2 deletions src/sha256.rs
Expand Up @@ -79,7 +79,7 @@ hex_fmt_impl!(Display, Hash);
hex_fmt_impl!(LowerHex, Hash);
index_impl!(Hash);
serde_impl!(Hash, 32);
borrow_slice_impl!(Hash, [u8; 32]);
borrow_slice_impl!(Hash);

impl HashTrait for Hash {
type Engine = HashEngine;
Expand Down Expand Up @@ -151,7 +151,7 @@ hex_fmt_impl!(Display, Midstate);
hex_fmt_impl!(LowerHex, Midstate);
index_impl!(Midstate);
serde_impl!(Midstate, 32);
borrow_slice_impl!(Midstate, [u8; 32]);
borrow_slice_impl!(Midstate);

impl Midstate {
/// Length of the midstate, in bytes.
Expand Down
2 changes: 1 addition & 1 deletion src/sha256d.rs
Expand Up @@ -29,7 +29,7 @@ hex_fmt_impl!(Display, Hash);
hex_fmt_impl!(LowerHex, Hash);
index_impl!(Hash);
serde_impl!(Hash, 32);
borrow_slice_impl!(Hash, [u8; 32]);
borrow_slice_impl!(Hash);

impl str::FromStr for Hash {
type Err = Error;
Expand Down
2 changes: 1 addition & 1 deletion src/sha512.rs
Expand Up @@ -127,7 +127,7 @@ hex_fmt_impl!(Display, Hash);
hex_fmt_impl!(LowerHex, Hash);
index_impl!(Hash);
serde_impl!(Hash, 64);
borrow_slice_impl!(Hash, [u8; 64]);
borrow_slice_impl!(Hash);

impl HashTrait for Hash {
type Engine = HashEngine;
Expand Down
2 changes: 1 addition & 1 deletion src/siphash24.rs
Expand Up @@ -209,7 +209,7 @@ hex_fmt_impl!(Display, Hash);
hex_fmt_impl!(LowerHex, Hash);
index_impl!(Hash);
serde_impl!(Hash, 8);
borrow_slice_impl!(Hash, [u8; 8]);
borrow_slice_impl!(Hash);

impl str::FromStr for Hash {
type Err = Error;
Expand Down
4 changes: 2 additions & 2 deletions src/util.rs
Expand Up @@ -76,7 +76,7 @@ macro_rules! index_impl(
);

macro_rules! borrow_slice_impl(
($ty:ty, $inner:ty) => (
($ty:ty) => (
impl ::std::borrow::Borrow<[u8]> for $ty {
fn borrow(&self) -> &[u8] {
&self[..]
Expand All @@ -90,7 +90,7 @@ macro_rules! borrow_slice_impl(
}

impl ::std::ops::Deref for $ty {
type Target = $inner;
type Target = [u8];

fn deref(&self) -> &Self::Target {
&self.0
Expand Down

0 comments on commit 7812a74

Please sign in to comment.