Reputation: 1901
I see that before Rust 1.0, there used to be functions like std::mem::from_be16
as well as core::mem::from_be16
. The documentation for both modules claims that all of the byte swapping routines are deprecated, and indeed they were removed for Rust 1.0.
Is there anything built into Rust which can do the swap and is not deprecated or would I have to implement my own?
Upvotes: 4
Views: 4201
Reputation: 2374
Methods like u16::swap_bytes
sound more relevant to the wording of the question.
Upvotes: 3
Reputation: 79
You want to use methods like i32::from_be
.
For future reference if you run code with deprecated functions the recommended replacement should be shown by the compiler or alternatively view the source code of the function which should have something like this
#[deprecated = "use `i32::from_be` instead"]
Upvotes: 3