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.
This commit is contained in:
parent
089043546f
commit
a20d0bc4eb
|
@ -71,13 +71,14 @@ where
|
||||||
pub fn from_engine(e: HashEngine) -> Hash<T> { from_engine(e) }
|
pub fn from_engine(e: HashEngine) -> Hash<T> { from_engine(e) }
|
||||||
|
|
||||||
/// Copies a byte slice into a hash object.
|
/// Copies a byte slice into a hash object.
|
||||||
|
#[deprecated(since = "TBD", note = "Use `from_byte_array` instead.")]
|
||||||
pub fn from_slice(sl: &[u8]) -> Result<Hash<T>, FromSliceError> {
|
pub fn from_slice(sl: &[u8]) -> Result<Hash<T>, FromSliceError> {
|
||||||
if sl.len() != 32 {
|
if sl.len() != 32 {
|
||||||
Err(FromSliceError { expected: 32, got: sl.len() })
|
Err(FromSliceError { expected: 32, got: sl.len() })
|
||||||
} else {
|
} else {
|
||||||
let mut ret = [0; 32];
|
let mut ret = [0; 32];
|
||||||
ret.copy_from_slice(sl);
|
ret.copy_from_slice(sl);
|
||||||
Ok(Self::internal_new(ret))
|
Ok(Self::from_byte_array(ret))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue