rust-lang / rust-lang/rust-clippy
Use `NonZero<T>` instead of `NonZeroT`
Open
@TennyZhuang is already working on this.
Since Jul 3, 2024.
A-lint
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
NonZero<T> stabilized with Rust 1.79.0. This allows NonZeroI32 to be written as NonZero<i32>.
Advantage
- More readable.
- Reduce imports.
- Can specify aliases for primitive integer types (e.g.,
NonZero<c_int>).
Drawbacks
MSRV is 1.79.0.
Example
let x = NonZeroI32::new(42).unwrap();
Could be written as:
let x = NonZero::<i32>::new(42).unwrap();
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.