Implement Num from num-traits #480
Conversation
Thanks! I usually don't like adding more features based on third-party libs, because it their breaking changes will be our breaking changes (semver). However I don't really mind in this case if you have a good use-case for it. |
I think, since this is gated behind features, you could do a I'll get the changes done tomorrow for the other comments. |
Looks good, thanks! (a note for maintainers: this is a non-breaking change) |
|
||
//! num-traits support for uint. | ||
|
||
#![cfg_attr(not(feature = "std"), no_std)] |
niklasad1
Dec 23, 2020
•
Member
I don't understand why this is needed?
I don't understand why this is needed?
SamWilsn
Dec 24, 2020
Author
Contributor
Bit of a leftover from moving from_str_radix
into the uint
crate. I don't believe this crate needs it ever, but there is a feature that enables std
in uint
and num-traits
.
Bit of a leftover from moving from_str_radix
into the uint
crate. I don't believe this crate needs it ever, but there is a feature that enables std
in uint
and num-traits
.
LGTM |
@@ -22,6 +22,7 @@ use fixed_hash::{construct_fixed_hash, impl_fixed_hash_conversions}; | |||
#[cfg(feature = "scale-info")] | |||
use scale_info::TypeInfo; | |||
use uint::{construct_uint, uint_full_mul_reg}; | |||
pub use uint::{FromStrRadixErr, FromStrRadixErrKind}; |
ordian
Dec 24, 2020
Member
hmm, I overlooked this line, seems redundant
we could return uint::FromStrRadixErr
in impls/num-traits
instead of $crate::...
hmm, I overlooked this line, seems redundant
we could return uint::FromStrRadixErr
in impls/num-traits
instead of $crate::...
SamWilsn
Dec 24, 2020
Author
Contributor
I'm not super familiar with the macro hygiene rules, but what if the downstream crate did a extern crate uint as floop
?
I'm not super familiar with the macro hygiene rules, but what if the downstream crate did a extern crate uint as floop
?
ordian
Dec 24, 2020
Member
yeah, fair point, we can do what impl/rlp
does, but still this like seems redundant
yeah, fair point, we can do what impl/rlp
does, but still this like seems redundant
I'll address the nits in a follow-up. |
Implementing the
Num
trait makes theU256
(and other) number types easier to work with, specifically withfrom_str_radix
.