I am writing a library that encodes/decodes data to/from a binary format. Part of the format is numbers, which I'm using Rust's native primitive types for (like i8
, i64
, f32
etc.).
Is there an easy, built-in way to convert these data types into/from binary, i.e. convert a f64
/f32
/i64
/etc. into a Vec<u8>
? Likewise is there a way to convert 4 u8
s (in a Vec<u8>
say) into an f32
?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…