You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NonZero being generic is definitely cool and it's nice that you can use c_int, but I don't see how this helps users when they've already got a NonZeroI32 and are only interested in that.
I don't think there's any readability difference or that it reduces imports when you specifically need NonZeroI32 and that only in a file; you either import NonZero or you import NonZeroI32.
Can you provide a use case for where this lint would have helped?
@y21 I think it's useful when you need multiple types.
use core::num::{NonZeroI32,NonZeroU32,NonZeroU8};let x = NonZeroU8::new(42).unwrap();let x = NonZeroI32::new(42).unwrap();let x = NonZeroU32::new(42).unwrap();
Could be written as:
use core::num::NonZero;let x = NonZero::<u8>::new(42).unwrap();let x = NonZero::<i32>::new(42).unwrap();let x = NonZero::<u32>::new(42).unwrap();
Uh oh!
There was an error while loading. Please reload this page.
What it does
NonZero<T>
stabilized with Rust 1.79.0. This allowsNonZeroI32
to be written asNonZero<i32>
.Advantage
NonZero<c_int>
).Drawbacks
MSRV is 1.79.0.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: