isaacholt100 / bnum

Arbitrary, fixed size numeric types that extend the functionality of primitive numeric types in Rust.
https://crates.io/crates/bnum
Other
73 stars 10 forks source link

Implement conversion traits based on integer size #3

Open isaacholt100 opened 2 years ago

isaacholt100 commented 2 years ago

Current behaviour is that From<uN> is implemented for all sizes of BUint<N>, but if e.g. a. U80 was created (with the u8_digit Cargo feature enabled), then this would not be ideal, as From<u128> could fail, and so the conversion trait should be TryFrom instead.

This could be implemented using bounds on N, but unfortunately it would rely on the unstable and incomplete nightly feature generic_const_exprs. For now, I think that is the only solution.