fn gen_padding_32bit(len: usize) -> &'static [u8] {
&[b' ', b' ', b' '][0..(4 - (len & 3)) & 3]
}
My understanding of the first pair of brackets is it represents an array of 3 byte literals, but what is the meaning/intention of the second pair [0..(4 - (len & 3)) & 3]?
In the code that you shared, the start of the range is 0, and the end of the range is ((4 - (len & 3)) & 3), which I think is an optimized way of writing something like this:
{
let array = [b' ', b' ', b' '];
let len = max(len, 3);
let mut end = 4 - len;
end = max(end, 3);
&array[0..end]
}