diff --git a/CHANGELOG.md b/CHANGELOG.md index 46d04b3471..4a67bc2166 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `tezos_data_encoding`: The `NomReader` trait is now explicitly parameterized by the lifetime of the input byte slice. +- Altered hashes to implement `AsRef<[u8]>` instead of `AsRef>`. ### Deprecated diff --git a/crypto/src/blake2b.rs b/crypto/src/blake2b.rs index 1a3aea1f6e..c98b2c3df2 100644 --- a/crypto/src/blake2b.rs +++ b/crypto/src/blake2b.rs @@ -101,7 +101,7 @@ where // this implementation will calculate the same hash [5, 5] two times. pub fn merkle_tree(list: &[Leaf]) -> Result, Blake2bError> where - Leaf: AsRef>, + Leaf: AsRef<[u8]>, { use std::ops::{Index, RangeFrom, RangeTo}; @@ -156,7 +156,7 @@ where degree: u32, ) -> Result, Blake2bError> where - Leaf: AsRef>, + Leaf: AsRef<[u8]>, { match degree { 0 => digest_256(list[0].as_ref()), diff --git a/crypto/src/hash.rs b/crypto/src/hash.rs index 3478e077cd..a6b42b5723 100644 --- a/crypto/src/hash.rs +++ b/crypto/src/hash.rs @@ -51,7 +51,7 @@ mod prefix_bytes { pub type Hash = Vec; -pub trait HashTrait: Into + AsRef { +pub trait HashTrait: Into + AsRef<[u8]> { /// Returns this hash type. fn hash_type() -> HashType; @@ -171,8 +171,8 @@ macro_rules! define_hash { } } - impl std::convert::AsRef for $name { - fn as_ref(&self) -> &Hash { + impl std::convert::AsRef<[u8]> for $name { + fn as_ref(&self) -> &[u8] { &self.0 } }