1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-05-10 12:46:04 +02:00

allow for construction of hash in const fn context

This commit is contained in:
Inanna Malick 2020-04-22 19:17:56 -07:00
parent fcb4b83419
commit 0031abcebd

View File

@ -198,6 +198,12 @@ fn counter_high(counter: u64) -> u32 {
#[derive(Clone, Copy, Hash)]
pub struct Hash([u8; OUT_LEN]);
/// Provided to allow for construction of magic hash values (eg null commit in git as [0; OUT_LEN])
pub const fn construct_magic_hash(bytes: [u8; OUT_LEN]) -> Hash {
Hash(bytes)
}
impl Hash {
/// The bytes of the `Hash`. Note that byte arrays don't provide
/// constant-time equality checking, so if you need to compare hashes,