Closed
Description
What it does
Starting in Rust 1.51, all integer types will have a ::BITS constant for the number of bits in the type. std::mem::size_of::<usize>() * 8
can be replaced with usize::BITS
and similarly for all signed and unisigned integers. This lint suggests such a change.
Categories (optional)
- Kind: clippy::style
What is the advantage of the recommended code over the original code
For example:
- One fewer function call (saving several nanoseconds)
- Easier to read
Drawbacks
None.
Example
std::mem::size_of::<usize>() * 8
Could be written as:
usize::BITS