]> git.lizzy.rs Git - rust.git/commit
Stabilize const for integer {to,from}_{be,le,ne}_bytes methods
authorTrevor Spiteri <tspiteri@ieee.org>
Sat, 22 Feb 2020 13:03:46 +0000 (14:03 +0100)
committerTrevor Spiteri <tspiteri@ieee.org>
Sat, 22 Feb 2020 13:03:46 +0000 (14:03 +0100)
commitd15a98b87815850ef9dd11564e896b6f19b724c3
treec99c374a6aee399b457c0f69b74ee79e8e2ffde3
parent03d2f5cd6c634b1fdcd26b036009aa4dce37fdfc
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

    (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
src/test/ui/consts/const-int-conversion-rpass.rs