]> git.lizzy.rs Git - rust.git/commit - src/tools/clippy
Rollup merge of #51919 - tbu-:pr_num_to_from_bytes2, r=SimonSapin
authorkennytm <kennytm@gmail.com>
Sat, 4 Aug 2018 09:19:38 +0000 (17:19 +0800)
committerkennytm <kennytm@gmail.com>
Sat, 4 Aug 2018 09:19:38 +0000 (17:19 +0800)
commit52db0ed161cd917908356cdd02624f9dd300966b
tree9f380d2c15da850a8e6a0eb386993e9d574f1cb8
parentaefa307c1fce043062d9d811f91476c0b22c6a6d
parent0ddfae5ba2d0104a33f3a7162571b761458f0464
Rollup merge of #51919 - tbu-:pr_num_to_from_bytes2, r=SimonSapin

Provide `{to,from}_{ne,le,be}_bytes` functions on integers

If one doesn't view integers as containers of bytes, converting them to
bytes necessarily needs the specfication of encoding.

I think Rust is a language that wants to be explicit. The `to_bytes`
function is basically the opposite of that – it converts an integer into
the native byte representation, but there's no mention (in the function
name) of it being very much platform dependent. Therefore, I think it
would be better to replace that method by three methods, the explicit
`to_ne_bytes` ("native endian") which does the same thing and
`to_{le,be}_bytes` which return the little- resp. big-endian encoding.