-
Notifications
You must be signed in to change notification settings - Fork 70
Add const-friendly NonZero::new_unwrap
#602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Makes it so users can have `NonZero` constants.
|
There used to be a |
|
The constructor is also what's checking the Perhaps instead until |
I can add the |
You mean bring back a variant of what 0.5.5 had? impl<const LIMBS: usize> NonZero<Uint<LIMBS>> {
/// Creates a new non-zero integer in a const context.
/// The second return value is `FALSE` if `n` is zero, `TRUE` otherwise.
pub const fn const_new(n: Uint<LIMBS>) -> (Self, CtChoice) {
(Self(n), n.ct_is_nonzero())
}
}…but without |
|
Yes, I forget offhand why we got rid of that, but for defining constants a |
|
I found a workaround for my concrete issue using I had a stab at making a panicking |
|
Sure, that works. You could also implement it with |
|
Is there anything left to do here before merging? |
Co-authored-by: Tony Arcieri <[email protected]>
NonZero::new_unwrap
Makes it so users can have
NonZeroconstants.