-
Couldn't load subscription status.
- Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lints
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>() * 8Could be written as:
usize::BITSMetadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints