Unnamed repository; edit this file 'description' to name the repository.
Rollup merge of #149295 - kornelski:endian_bytes, r=Mark-Simulacrum
Suggest _bytes versions of endian-converting methods As pointed out [in this article](https://purplesyringa.moe/blog/ntoh-hton-is-a-bad-api/), the `int.to_be()`/`int.to_le()` functions are technically returning a wrong type, because endian-specific representations of integers and Rust's always-native-endian integers are different things. I wanted to make the docs state more directly that byte swapping will result in the type having a "wrong" value, but I wasn't sure whether to delve into the special case of palindrome-like values (`0x12343412`) not changing. I've updated the docs to suggest `{to,from}_[lb]e_bytes()` instead. These methods use `[u8; _]` for endian-specific representations, which is a different type than the native-endian `u16`/`u32`/`u64`, and this is a type-safety improvement.
Stuart Cook 5 months ago
parent 276212c · parent 5bd6eaa · commit e5876fb
0 files changed, 0 insertions, 0 deletions