parity-common icon indicating copy to clipboard operation
parity-common copied to clipboard

From<i64> impl is invalid

Open benluelo opened this issue 2 years ago • 2 comments

This implementation is invalid: https://github.com/paritytech/parity-common/blob/a5ef7308d6986e62431e35d3156fed0a7a585d39/uint/src/uint.rs#L1349-L1356

As per the docs on From:

Note: This trait must not fail. The From trait is intended for perfect conversions. If the conversion can fail or is not perfect, use TryFrom.

benluelo avatar Jul 07 '23 19:07 benluelo

From<i128> is also invalid: https://github.com/paritytech/parity-common/blob/a5ef7308d6986e62431e35d3156fed0a7a585d39/uint/src/uint.rs#L487-L494

benluelo avatar Jul 07 '23 19:07 benluelo

This initial impl predates the stabilization of TryFrom trait and should be replaced by that (breaking change) indeed nowadays.

ordian avatar Jul 07 '23 21:07 ordian