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
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 current ToBigInt implementors do not fail at all ( ToBigUint does fail, but only because they are implemented for signed integers as well).
Given that BigInt and BigUint already implements FromStr (that would correspond to impl<'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:
Make ToBigInt::to_bigint and ToBigUint::to_biguint return BigInt and BigUint respectively.
Remove implementations of ToBigUint for signed integers and BigInt.
Add a new into_biguint (since it's more efficient, and does not confuse users of ToBigUint) to BigInt, which returns Option<BigUint>. We may also have into_bigint to BigUint, at expense of symmetry (it becomes asymmetric since it should not return Option<BigInt>).
The text was updated successfully, but these errors were encountered:
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: