For a programming language VM I have been working on lately I need to create a stack for data. I have decided to use a Vec<u8>
and then convert data to slices of u8
.
Although turning strings into u8
is trivially easy, turning f32
s and i32
s into u8
slices is less obvious. If this were C I would just do a cast; however, that doesn't seem to work in Rust.
What is the best way to convert these types into slices of u8
?