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.
More Related Contents:
- When is it appropriate to use an associated type versus a generic type?
- How do I print the type of a variable?
- Why can’t Rust infer the resulting type of Iterator::sum?
- How do I print in Rust the type of a variable?
- Is there a way to create a data type that only accepts a range of values?
- How to idiomatically convert between u32 and usize?
- biggest integer that can be stored in a double
- Which is the first integer that an IEEE 754 float is incapable of representing exactly?
- How can I have a collection of objects that differ by their associated type?
- JAXB: How to change XJC-generated classes names when attr type is specified in XSD?
- Is there a way to convert integers to bools in go or vice versa?
- Python method-wrapper type?
- How to create a circularly referenced type in TypeScript?
- golang type assertion using reflect.Typeof()
- Why can I type alias functions and use them without casting?
- Ensure a type implements an interface at compile time in Go
- Why IEEE754 single-precision float has only 7 digit precision?
- Defining TypeScript callback type
- How does Python 2 compare string and int? Why do lists compare as greater than numbers, and tuples greater than lists?
- Why can I return a reference to a local literal but not a variable?
- Conflicting implementations of trait in Rust
- How do I use static lifetimes with threads?
- Oracle JDBC and Oracle CHAR data type
- Processing vec in parallel: how to do safely, or without using unstable features?
- Why and how does ([![]]+[][[]])[+!+[]+[+[]]] evaluate to the letter “i”? [duplicate]
- How to change type of target column when doing := by group in a data.table in R?
- Reading from a TcpStream with Read::read_to_string hangs until the connection is closed by the remote end
- How does Javascript know what type a variable is?
- How can I initialize an array using a function? [duplicate]
- Static return type of Scala macros