I'm writing code that takes 64-byte blocks and I want to enforce this size at the type level:
fn f(buf: &[u8; 64]) { ... }
However, the data is coming in as a slice &[u8]. So, I'd like to be able to take subspaces of this and convert to &[u8; 64]. It turns out that it the following conversion works:
let buf = (0..32).collect::<Vec<u8>>();
let z: &[u8; 32] = &(&buf[..]).try_into().unwrap();
But the following doesn't:
let buf = (0..64).collect::<Vec<u8>>();
let z: &[u8; 64] = &(&buf[..]).try_into().unwrap();
The difference being from 0 to 32 inclusive, the conversion works, but not for sizes above 32. What can I do to enable this &[u8] -> &[u8; 64] conversion without manually doing data copy?