-
Notifications
You must be signed in to change notification settings - Fork 149
ToBigInt
and ToBigUint
should not return an error
#10
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
Comments
Can a core team member comment on this? It's an easy change to make, and it can have huge benefits. I was thinking of changing all the |
@huonw, @alexcrichton, do you have thoughts on this? I'd like to implement it. |
I'd rather use Expanding generic |
FYI, num-bigint has its own repo now: https://github.com/rust-num/num-bigint But I think my prior comment still stands, and we do have |
Wednesday Apr 16, 2014 at 10:23 GMT
For earlier discussion, see rust-lang/rust#13555
This issue was labelled with: in the Rust repository
It is a side effect of #9250, which added those traits as a special case of the
FromPrimitive
trait. This is rather strange, since the currentToBigInt
implementors do not fail at all (ToBigUint
does fail, but only because they are implemented for signed integers as well).Given that
BigInt
andBigUint
already implementsFromStr
(that would correspond toimpl<'a> ToBigInt for &'a str
and so on), it would be better to make them implemented only for types that would definitely convertible to the big integers without an error. More precisely:ToBigInt::to_bigint
andToBigUint::to_biguint
returnBigInt
andBigUint
respectively.ToBigUint
for signed integers andBigInt
.into_biguint
(since it's more efficient, and does not confuse users ofToBigUint
) toBigInt
, which returnsOption<BigUint>
. We may also haveinto_bigint
toBigUint
, at expense of symmetry (it becomes asymmetric since it should not returnOption<BigInt>
).The text was updated successfully, but these errors were encountered: