This works, but is very convoluted:
let mut hasher = Sha256::new();
hasher.update(foo);
hasher.update(bar);
let hash = hasher.finalize();
let hash_array: [u8; 16] = hash[0..16].try_into().expect("slice with incorrect length");
let hash128 = u128::from_le_bytes(hash_array);
Is there a way of doing this without:
let hash_array: [u8; 16] = hash[0..16].try_into().expect("slice with incorrect length");
I'm handling a condition which cannot happen, as I know that sha256 produces 32 bytes. How can I tell the compiler that?