I'm computing the SHA256 of a given data:
let hashvalue = sha2::Sha256::digest(&data);
After computing it, I want to put this value into a field of my struct:
let x = Hash { value: hashvalue };
However, the Hash
struct expects the type of value [u8; 32]
, while my hashvalue
variable is of type GenericArray<u8, ?>
. How can I convert hashvalue
into the correct type? I tried to use as [u8; 32]
and arr!
but it didn't work.