The `zeroize_derive` crate has quite a few dependencies, and in
particular `syn` is a fairly large one with not-insignificant compile
times.
The usages of `zeroize` are fairly trivial with two impls zeroing a
total of three fields, which makes them easy to write by hand.
It takes more crate dependencies for the proc macro to do that
(`proc-macro2`, `quote`, `syn`, `synstructure`, and `zeroize_derive`
itself) than there are fields being zeroized, so I think it makes sense
to ditch the additional dependencies and write these impls by hand.
Upgrades the edition, with changes primarily performed by
`cargo fix --edition`.
In order to keep the changes to a minimum, this doesn't include
automated idiom fixes (i.e. `cargo fix --edition-idioms`).
This is needed to unblock the edition upgrade for the RSA crate:
https://github.com/RustCrypto/RSA/pull/135
* no_std support
* Use integer log2 when possible to estimate allocations
* Remove std features from a few dependencies
* Use libm for missing funcs in nostd environment
* Use autocfg to detect presence of i128
* Better CI test for nostd environment
* Move benchmark to a separate crate
* Make the tests pass in no_std builds
* Use thumbv7m target for nostd build test
* Add documentation about the no-std compatibility
* Make zeroize and prime features no_std-compatible
* Test each feature in nostd context
* Fix mac test to work in no_std environment
* Avoid using thread_rng in nostd tests
* Fix prime tests in nostd mode
* Fix all warnings and errors
* Only test nostd builds on nightly on travis
* Travis: Only do nostd builds on nightly
This commit implements num-integer::Roots trait
for BigInt and BigUint types, and also adds sqrt,
cbrt, nth_root as inherent methods to allow access
to them without importing Roots trait. For each
type tests were added as submodules in the roots
test module.
Signed-off-by: Manca Bizjak <manca.bizjak@xlab.si>
We don't actually support `no_std` yet, and probably won't until `alloc`
is stable. We're just reserving this ability with the "std" feature
now, and compilation will fail without.
It was pointed out in the blog post [Big Integers in Zig] that we don't
have a special case in `num-bigint` for single-digit divisors. While
you can already get this optimization by dividing directly by `u32`,
it's easy to make small `BigUint` divisors work like this too.
$ cargo benchcmp baseline single-div
name baseline ns/iter single-div ns/iter diff ns/iter diff % speedup
factorial_div_biguint 5,638,353 1,005,488 -4,632,865 -82.17% x 5.61
`BigInt` will also gain from this, since it uses `BigUint` division
internally.
Running [zig-bn's facdiv-rs] shows a nice improvement too. My i7-7700K
with Rust 1.26 goes from 4.15 seconds to just 0.65 -- a 6.38x speedup!
[Big Integers in Zig]: https://tiehuis.github.io/big-integers-in-zig#division-test-single-limb
[zig-bn's facdiv-rs]: https://github.com/tiehuis/zig-bn/tree/master/bench/facdiv/crate-facdiv-rs