-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Hello!
I was looking at the crate and read that new
will panic if the value cannot be represented by the type.
Understandably, uX's types require the new
-function to be constructed as they are not integer primitives thus u31
cannot utilise the same construction as e.g. u32
.
Nonetheless, when we look at e.g. NonZeroU32's new (and the other NonZero
-types) - which is a custom integer too - it returns Option
instead of panicking when the conditions are not met. This might an interesting guideline to follow.
Hence my question: Might changing uX's new
-functions to return Option
be of interest?
Mirroring new_unchecked
could be feasible too but the std
does not run assertions in them.
If wanted, I would be willing to perform this change : )
Thanks for your time!