merge 2 x [u8; 4] into [u8; 8]
Is there a way to safely merge 2 \[u8; 4\] into a \[u8; 8\] ?
I'm actually doing it like this:
let high_half: [u8; 4] = ...;
let low_half: [u8; 4] = ...;
let mut bits = [0; 8];
bits[..4].copy_from_slice(&high_half);
bits[4..].copy_from_slice(&low_half);
but I'm not satisfied, copy\_from\_slice can panic but I know the size is good.
What would really be perfect would be to be able to do a safe transmute like this:
let bits = transmute<[[u8;4];2], [u8; 8]>([high_half, low_half]);
Is there a way to do this safely ? I'm not against unsafe, but I can't use it for this project.