Pregunta

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?

¿Fue útil?

Solución

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"]

Otros consejos

Methods like u16::swap_bytes sound more relevant to the wording of the question.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top