From ca823945fc2e94a8729b009361916c28f2d77c37 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 11 Jul 2024 14:08:31 +1000 Subject: [PATCH] Manually implement AsRef (remove Borrow) Currently we are using a macro to implement `AsRef` and `Borrow` for `sha256::Midstate`. In preparation for adding a length field to the `Midstate` remove the implementation of `Borrow` but keep `AsRef`. API breaking change. --- hashes/src/sha256.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hashes/src/sha256.rs b/hashes/src/sha256.rs index 5a54c0601..00c4d66e0 100644 --- a/hashes/src/sha256.rs +++ b/hashes/src/sha256.rs @@ -8,7 +8,7 @@ use core::arch::x86::*; use core::arch::x86_64::*; use core::ops::Index; use core::slice::SliceIndex; -use core::{cmp, fmt}; +use core::{cmp, convert, fmt}; #[cfg(doc)] use crate::sha256t; @@ -198,7 +198,9 @@ impl fmt::Debug for Midstate { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:#}", self) } } -borrow_slice_impl!(Midstate); +impl convert::AsRef<[u8]> for Midstate { + fn as_ref(&self) -> &[u8] { &self.0 } +} impl> Index for Midstate { type Output = I::Output;