Are you literally me 2 months ago? I was trying to implement the same HashFunction trait as yours and I finally settled with:
pub trait HashFunction<const OUTPUT_SIZE: usize> {
fn hash(data: &[u8]) -> [u8; OUTPUT_SIZE];
}
I believe this approach has some shortcomings in my case, but it has been a while and I didn't remember anything.Also for the Rust crowd, is it possible to do something like this?
pub trait HashFunction<const OUTPUT_SIZE: usize> {
// I want Output to always be [u8; OUTPUT_SIZE], but using associated type means
// whatever implements HashFunction can redefine Output.
type Output;
fn hash(data: &[u8]) -> Output;
}