-
Notifications
You must be signed in to change notification settings - Fork 218
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
Implement Num from num-traits #480
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I overlooked this line, seems redundant
we could return uint::FromStrRadixErr
in impls/num-traits
instead of $crate::...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super familiar with the macro hygiene rules, but what if the downstream crate did a extern crate uint as floop
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
* The time crate after 0.2 is unergonomic to use; just use chrono (paritytech#458) The 0.2 series of `time` doesn't make it easy to "just" create a timestamp. The `chrono` crate uses `time` v0.1 and is, I believe, what users like us should be using. So let's just do that. * build(deps): update send_wrapper requirement from 0.3.0 to 0.5.0 (paritytech#461) Updates the requirements on [send_wrapper](https://github.com/thk1/send_wrapper) to permit the latest version. - [Release notes](https://github.com/thk1/send_wrapper/releases) - [Changelog](https://github.com/thk1/send_wrapper/blob/master/CHANGELOG.md) - [Commits](thk1/send_wrapper@v0.3.0...v0.5.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * rlp: add bytes impls (paritytech#459) * rlp: add bytes impls * add tests * rlp: Fix buffer indexing (paritytech#462) * Fix buffer indexing * test for clear * rlp: store test bytes in hex literals (paritytech#465) * Make RLP optional in several crates (paritytech#466) * bump versions and update changelogs (paritytech#463) * update other dependencies (paritytech#471) * ethereum-types/rlp should pull primitive-types/rlp (paritytech#474) * uint: optimize FromStr, make it no_std-compatible (paritytech#468) * Add from_str bench * uint: optimize FromStr, make it no_std-compatible * custom error type * fmt::Display is actually available in core * Error::source for FromHexError * uppercase consts * additional tests * kvdb-rocksdb: replace tempdir with tempfile(paritytech#350) (paritytech#477) * chore(deps): cargo upgrade parking_lot --all (paritytech#470) * chore(deps): cargo upgrade parking_lot --all * chore(deps): bump versions breaking change. * chore: update changelog * kvdb * kvdb-memorydb * kvdb-rocksdb * parity-util-mem * fix nits * fix: kvdb-web add missing changelog entry * fix: bad merge * fix more nits: use breaking label * [kvdb-memorydb]: add `wasm-bindgen` feature flag * grumbles: remove `wasm-bindgen` feature flag * Add hack only in `kvdb-web` * Remove feature flag `wasm-bindgen` from `kvdb-memorydb` * Bump bytes to 1.0 (paritytech#482) * Implement Num from num-traits (paritytech#480) * parity-crypto: remove UB test (paritytech#484) * parity-crypto: remove UB test * rlp: fix unused import * parity-crypto: upgrade deps (paritytech#483) * update some dev-dependencies (paritytech#493) Signed-off-by: koushiro <koushiro.cqx@gmail.com> * fix: make from_str parse 0x-prefixed strings (paritytech#487) * fix: make from_str parse 0x-prefixed strings * fix(uint): make from_str parse 0x-prefixed strings * chore: address review styling comments * fix: tabs instead of spaces * chore: cargo fmt * fix: use strip_prefix instead of starts_with * build(deps): update impl-trait-for-tuples requirement (paritytech#490) Updates the requirements on [impl-trait-for-tuples](https://github.com/bkchr/impl-trait-for-tuples) to permit the latest version. - [Release notes](https://github.com/bkchr/impl-trait-for-tuples/releases) - [Commits](https://github.com/bkchr/impl-trait-for-tuples/commits/v0.2) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * primitive-types: address nits of paritytech#480 (paritytech#485) * primitive-types: address nits of paritytech#480 * fix ethereum-types * Remove deprecated FromStr/TryFrom impls for Secret (paritytech#495) * Remove deprecated FromStr/TryFrom impls for Secret * update CHANGELOG * build(deps): update secp256k1 requirement from 0.19.0 to 0.20.0 (paritytech#496) Updates the requirements on [secp256k1](https://github.com/rust-bitcoin/rust-secp256k1) to permit the latest version. - [Release notes](https://github.com/rust-bitcoin/rust-secp256k1/releases) - [Changelog](https://github.com/rust-bitcoin/rust-secp256k1/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-bitcoin/rust-secp256k1/commits) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andronik Ordian <write@reusable.software> * build(deps): update smallvec requirement from 0.6.10 to 1.6.0 (paritytech#494) Updates the requirements on [smallvec](https://github.com/servo/rust-smallvec) to permit the latest version. - [Release notes](https://github.com/servo/rust-smallvec/releases) - [Commits](https://github.com/servo/rust-smallvec/commits/v1.6.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andronik Ordian <write@reusable.software> * build(deps): update rand requirement from 0.7.2 to 0.8.0 (paritytech#488) * build(deps): update rand requirement from 0.7.2 to 0.8.0 Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](rust-random/rand@0.7.3...0.8.0) Signed-off-by: dependabot[bot] <support@github.com> * Seed from u64 * uint: use rand 0.7 for quickcheck feature * kvdb-rocksdb: fix compilation for benches * parity-crypto: remove unused dep and fix a warning * cargo fmt and another unused dep Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andronik Ordian <write@reusable.software> Co-authored-by: David Palm <dvdplm@gmail.com> * build(deps): update rand_xorshift requirement from 0.2.0 to 0.3.0 (paritytech#491) Updates the requirements on [rand_xorshift](https://github.com/rust-random/rngs) to permit the latest version. - [Release notes](https://github.com/rust-random/rngs/releases) - [Commits](https://github.com/rust-random/rngs/commits/rand_xorshift-0.3.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * update changelogs and bump uint (paritytech#486) * update changelogs and bump uint * update ethereum-types changelog * update uint changelog * tabs * fixed-hash: bump to 0.7 * bump keccak-hash to 0.6.0 * contract-address: bump keccak-hash to 0.6 * update changelogs after publishing * bump fs-swap (paritytech#498) * triehash: patch release (paritytech#499) * fix clippy warning (paritytech#504) * add a test for paritytech#507 (paritytech#508) * add a test for paritytech#507 * CI: test uint on a big-endian platform * a workaround for gmp * grumbles * bump byteorder to 1.4.2 * ethereum-types: fix wasm builds for serialize feature (paritytech#503) * ethbloom: do not pull std for 'serialize' feature * ethereum-types: do not pull std for 'serialize' feature * CI: check wasm builds for ethbloom and ethereum-types * fix wasm target * CI: remove redundant check * CI: fix wasm target install * update changelogs * remove parity-runtime (paritytech#511) * Update codec and crates depending (paritytech#510) Co-authored-by: Andronik Ordian <write@reusable.software> Co-authored-by: David <dvdplm@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Artem Vorotnikov <artem@vorotnikov.me> Co-authored-by: Andronik Ordian <write@reusable.software> Co-authored-by: Frost Red Lee <frostredlee@gmail.com> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> Co-authored-by: Qinxuan Chen <koushiro.cqx@gmail.com> Co-authored-by: Georgios Konstantopoulos <me@gakonst.com> Co-authored-by: Xiliang Chen <xlchen1291@gmail.com> Co-authored-by: honeywest <50997103+honeywest@users.noreply.github.com> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Implementing the
Num
trait makes theU256
(and other) number types easier to work with, specifically withfrom_str_radix
.