This crate contains unsafe code in a few places to bypass non-zero checks in NonZeroU32 type: unsafe { NonZeroU32::new_unchecked(...) }.
Consider removing the unsafe code and instead just using NonZeroU32::new(...) and panicking if it returns None, or at least providing code paths that can be used by the user without running any unsafe code.
Making this change is unlikely to make any meaningful difference in performance: a non-zero check is an operation that is about as cheap as it gets. In practice, collection performance is dominated by cache and memory effects.
This crate contains
unsafecode in a few places to bypass non-zero checks inNonZeroU32type:unsafe { NonZeroU32::new_unchecked(...) }.Consider removing the
unsafecode and instead just usingNonZeroU32::new(...)and panicking if it returnsNone, or at least providing code paths that can be used by the user without running anyunsafecode.Making this change is unlikely to make any meaningful difference in performance: a non-zero check is an operation that is about as cheap as it gets. In practice, collection performance is dominated by cache and memory effects.