As of Rust 1.32 you can use {to,from}_{ne,le,be}_bytes
for integral types.
let begin = 1234_i32;
let bytes = begin.to_ne_bytes();
let and_back = i32::from_ne_bytes(bytes);
For floating point you still have to rely on prior methods.
As of Rust 1.32 you can use {to,from}_{ne,le,be}_bytes
for integral types.
let begin = 1234_i32;
let bytes = begin.to_ne_bytes();
let and_back = i32::from_ne_bytes(bytes);
For floating point you still have to rely on prior methods.