]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #69373 - tspiteri:const_int_conversion, r=oli-obk
authorMazdak Farrokhzad <twingoow@gmail.com>
Wed, 11 Mar 2020 09:36:18 +0000 (10:36 +0100)
committerGitHub <noreply@github.com>
Wed, 11 Mar 2020 09:36:18 +0000 (10:36 +0100)
commit43079147f4fcc5c0a9019fb39acdc8aa3c384f65
treefca5051e24aad45b4fb287208fd65c32d49e178c
parenta7c2eef2aeb23f52efc4a4bfd240292d43a61798
parent87f0dc63a864c6d9a3c34aa4052762dbcd316c91
Rollup merge of #69373 - tspiteri:const_int_conversion, r=oli-obk

Stabilize const for integer {to,from}_{be,le,ne}_bytes methods

All of these functions can be implemented simply and naturally as const functions, e.g. `u32::from_le_bytes` can be implemented as
```rust
(bytes[0] as u32)
    | (bytes[1] as u32) << 8
    | (bytes[2] as u32) << 16
    | (bytes[3] as u32) << 24
```
So stabilizing the constness will not expose that internally they are implemented using transmute which is not const in stable.
src/libcore/lib.rs
src/libcore/num/mod.rs