From a20d0bc4eb380b025a66aa8dcc106fc6bebc72bb Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Thu, 5 Sep 2024 16:13:29 +0100 Subject: [PATCH] Deprecate `from_slice()` in sha256.rs Support for Rust arrays is now much better so slice-accepting methods that require a fixed length can be replaced with a method that accepts an array. `from_slice()` has been deprecated. A `from_byte_array()` function already exists to be used instead. --- hashes/src/sha256t.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hashes/src/sha256t.rs b/hashes/src/sha256t.rs index 655e58783..7f2fae50e 100644 --- a/hashes/src/sha256t.rs +++ b/hashes/src/sha256t.rs @@ -71,13 +71,14 @@ where pub fn from_engine(e: HashEngine) -> Hash { from_engine(e) } /// Copies a byte slice into a hash object. + #[deprecated(since = "TBD", note = "Use `from_byte_array` instead.")] pub fn from_slice(sl: &[u8]) -> Result, FromSliceError> { if sl.len() != 32 { Err(FromSliceError { expected: 32, got: sl.len() }) } else { let mut ret = [0; 32]; ret.copy_from_slice(sl); - Ok(Self::internal_new(ret)) + Ok(Self::from_byte_array(ret)) } }