2021 edition upgrade; MSRV 1.56
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
This commit is contained in:
parent
56576b592f
commit
2aade9ddcb
@ -1,6 +1,6 @@
|
||||
language: rust
|
||||
rust:
|
||||
- 1.36.0
|
||||
- 1.56.0
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
|
@ -12,6 +12,8 @@ license = "MIT/Apache-2.0"
|
||||
name = "num-bigint-dig"
|
||||
repository = "https://github.com/dignifiedquire/num-bigint"
|
||||
version = "0.7.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.56"
|
||||
readme = "README.md"
|
||||
build = "build.rs"
|
||||
autobenches = false
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
[](https://crates.io/crates/num-bigint-dig)
|
||||
[](https://docs.rs/num-bigint-dig)
|
||||

|
||||

|
||||
[](https://travis-ci.org/dignifiedquire/num-bigint)
|
||||
|
||||
Big integer types for Rust, `BigInt` and `BigUint`.
|
||||
@ -50,7 +50,7 @@ Release notes are available in [RELEASES.md](RELEASES.md).
|
||||
|
||||
## Compatibility
|
||||
|
||||
The `num-bigint` crate is tested for rustc 1.36 and greater.
|
||||
The `num-bigint` crate is tested for rustc 1.56 and greater.
|
||||
|
||||
## Alternatives
|
||||
|
||||
@ -59,8 +59,8 @@ crates may offer better performance with different trade-offs. The following
|
||||
table offers a brief comparison to a few alternatives.
|
||||
|
||||
| Crate | License | Min rustc | Implementation |
|
||||
| :------------------- | :------------- | :-------- | :------------- |
|
||||
| **`num-bigint-dig`** | MIT/Apache-2.0 | 1.36 | pure rust |
|
||||
| :------------------- | :------------- |:----------| :------------- |
|
||||
| **`num-bigint-dig`** | MIT/Apache-2.0 | 1.56 | pure rust |
|
||||
| [`num-bigint`] | MIT/Apache-2.0 | 1.15 | pure rust |
|
||||
| [`ramp`] | Apache-2.0 | nightly | rust and inline assembly |
|
||||
| [`rug`] | LGPL-3.0+ | 1.18 | bundles [GMP] via [`gmp-mpfr-sys`] |
|
||||
|
@ -2,7 +2,7 @@ use crate::big_digit::{BigDigit, DoubleBigDigit, BITS};
|
||||
use crate::bigint::Sign::*;
|
||||
use crate::bigint::{BigInt, ToBigInt};
|
||||
use crate::biguint::{BigUint, IntDigits};
|
||||
use integer::Integer;
|
||||
use crate::integer::Integer;
|
||||
use num_traits::{One, Signed, Zero};
|
||||
use alloc::borrow::Cow;
|
||||
use core::ops::Neg;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use integer::Integer;
|
||||
use crate::integer::Integer;
|
||||
use num_traits::{One, Signed, Zero};
|
||||
|
||||
use crate::BigInt;
|
||||
|
@ -28,7 +28,7 @@ pub fn mod_inverse(g: Cow<BigUint>, n: Cow<BigUint>) -> Option<BigInt> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use integer::Integer;
|
||||
use crate::integer::Integer;
|
||||
use num_traits::FromPrimitive;
|
||||
|
||||
use crate::traits::ModInverse;
|
||||
|
@ -23,7 +23,7 @@ use serde;
|
||||
#[cfg(feature = "zeroize")]
|
||||
use zeroize::Zeroize;
|
||||
|
||||
use integer::{Integer, Roots};
|
||||
use crate::integer::{Integer, Roots};
|
||||
use num_traits::{
|
||||
CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, FromPrimitive, Num, One, Pow, Signed,
|
||||
ToPrimitive, Zero,
|
||||
@ -32,14 +32,14 @@ use num_traits::{
|
||||
use self::Sign::{Minus, NoSign, Plus};
|
||||
use super::ParseBigIntError;
|
||||
use super::VEC_SIZE;
|
||||
use big_digit::{self, BigDigit, DoubleBigDigit};
|
||||
use biguint;
|
||||
use biguint::to_str_radix_reversed;
|
||||
use biguint::{BigUint, IntDigits};
|
||||
use crate::big_digit::{self, BigDigit, DoubleBigDigit};
|
||||
use crate::biguint;
|
||||
use crate::biguint::to_str_radix_reversed;
|
||||
use crate::biguint::{BigUint, IntDigits};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use IsizePromotion;
|
||||
use UsizePromotion;
|
||||
use crate::IsizePromotion;
|
||||
use crate::UsizePromotion;
|
||||
|
||||
use crate::algorithms::{extended_gcd, mod_inverse};
|
||||
use crate::biguint::IntoBigUint;
|
||||
|
@ -4,13 +4,13 @@ use rand::distributions::uniform::{SampleBorrow, SampleUniform, UniformSampler};
|
||||
use rand::prelude::*;
|
||||
use rand::Rng;
|
||||
|
||||
use BigInt;
|
||||
use BigUint;
|
||||
use Sign::*;
|
||||
use crate::BigInt;
|
||||
use crate::BigUint;
|
||||
use crate::Sign::*;
|
||||
|
||||
use big_digit::BigDigit;
|
||||
use bigint::{into_magnitude, magnitude};
|
||||
use integer::Integer;
|
||||
use crate::big_digit::BigDigit;
|
||||
use crate::bigint::{into_magnitude, magnitude};
|
||||
use crate::integer::Integer;
|
||||
#[cfg(feature = "prime")]
|
||||
use num_iter::range_step;
|
||||
use num_traits::Zero;
|
||||
@ -183,7 +183,6 @@ pub struct UniformBigInt {
|
||||
impl UniformSampler for UniformBigInt {
|
||||
type X = BigInt;
|
||||
|
||||
#[inline]
|
||||
#[inline]
|
||||
fn new<B1, B2>(low_b: B1, high_b: B2) -> Self
|
||||
where
|
||||
|
@ -61,16 +61,16 @@ fn exp(a: f64) -> f64 {
|
||||
libm::exp(a)
|
||||
}
|
||||
|
||||
use integer::{Integer, Roots};
|
||||
use crate::integer::{Integer, Roots};
|
||||
use num_traits::float::FloatCore;
|
||||
use num_traits::{
|
||||
CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, FromPrimitive, Num, One, Pow, ToPrimitive,
|
||||
Unsigned, Zero,
|
||||
};
|
||||
|
||||
use BigInt;
|
||||
use crate::BigInt;
|
||||
|
||||
use big_digit::{self, BigDigit};
|
||||
use crate::big_digit::{self, BigDigit};
|
||||
|
||||
use smallvec::SmallVec;
|
||||
|
||||
@ -86,8 +86,8 @@ use crate::algorithms::{div_rem, div_rem_digit, mac_with_carry, mul3, scalar_mul
|
||||
use crate::algorithms::{extended_gcd, mod_inverse};
|
||||
use crate::traits::{ExtendedGcd, ModInverse};
|
||||
|
||||
use ParseBigIntError;
|
||||
use UsizePromotion;
|
||||
use crate::ParseBigIntError;
|
||||
use crate::UsizePromotion;
|
||||
|
||||
/// A big unsigned integer type.
|
||||
#[derive(Clone, Debug)]
|
||||
|
66
src/lib.rs
66
src/lib.rs
@ -79,52 +79,33 @@
|
||||
//!
|
||||
//! ## Compatibility
|
||||
//!
|
||||
//! The `num-bigint` crate is tested for rustc 1.15 and greater.
|
||||
//! The `num-bigint-dig` crate is tested for rustc 1.56 and greater.
|
||||
//!
|
||||
//! ## `no_std` compatibility
|
||||
//!
|
||||
//! This crate is compatible with `no_std` environments from Rust 1.36. Note
|
||||
//! however that it still requires the `alloc` crate, so the user should ensure
|
||||
//! that they set a `global_allocator`.
|
||||
//! This crate is compatible with `no_std` environments.
|
||||
//!
|
||||
//! Note however that it still requires the `alloc` crate, so the user should
|
||||
//! ensure that they set a `global_allocator`.
|
||||
//!
|
||||
//! To use in no_std environment, add the crate as such in your `Cargo.toml`
|
||||
//! file:
|
||||
//!
|
||||
//! ```toml
|
||||
//! [dependencies]
|
||||
//! num-bigint = { version = "0.3", default-features=false }
|
||||
//! num-bigint-dig = { version = "0.8", default-features=false }
|
||||
//! ```
|
||||
//!
|
||||
//! Every features should be compatible with no_std environment, so feel free to
|
||||
//! add features like `prime`, `i128`, etc...
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/num-bigint/0.2")]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![no_std]
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[macro_use]
|
||||
extern crate alloc;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std as alloc;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
extern crate core;
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
extern crate rand;
|
||||
#[cfg(all(test, feature = "rand"))]
|
||||
extern crate rand_chacha;
|
||||
#[cfg(all(test, feature = "rand"))]
|
||||
extern crate rand_isaac;
|
||||
#[cfg(all(test, feature = "rand"))]
|
||||
extern crate rand_xorshift;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
extern crate serde;
|
||||
|
||||
#[cfg(feature = "zeroize")]
|
||||
extern crate zeroize;
|
||||
extern crate std;
|
||||
|
||||
#[macro_use]
|
||||
extern crate smallvec;
|
||||
@ -134,17 +115,10 @@ extern crate smallvec;
|
||||
extern crate lazy_static;
|
||||
|
||||
extern crate num_integer as integer;
|
||||
extern crate num_iter;
|
||||
extern crate num_traits;
|
||||
|
||||
#[cfg(feature = "prime")]
|
||||
extern crate byteorder;
|
||||
|
||||
extern crate libm;
|
||||
|
||||
use core::fmt;
|
||||
#[cfg(feature = "std")]
|
||||
use std::error::Error;
|
||||
use core::fmt;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
@ -158,7 +132,7 @@ pub mod prime;
|
||||
pub mod algorithms;
|
||||
pub mod traits;
|
||||
|
||||
pub use traits::*;
|
||||
pub use crate::traits::*;
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
mod bigrand;
|
||||
@ -186,7 +160,7 @@ enum BigIntErrorKind {
|
||||
|
||||
impl ParseBigIntError {
|
||||
fn __description(&self) -> &str {
|
||||
use BigIntErrorKind::*;
|
||||
use crate::BigIntErrorKind::*;
|
||||
match self.kind {
|
||||
Empty => "cannot parse integer from empty string",
|
||||
InvalidDigit => "invalid digit found in string",
|
||||
@ -219,18 +193,18 @@ impl Error for ParseBigIntError {
|
||||
}
|
||||
}
|
||||
|
||||
pub use biguint::BigUint;
|
||||
pub use biguint::IntoBigUint;
|
||||
pub use biguint::ToBigUint;
|
||||
pub use crate::biguint::BigUint;
|
||||
pub use crate::biguint::IntoBigUint;
|
||||
pub use crate::biguint::ToBigUint;
|
||||
|
||||
pub use bigint::negate_sign;
|
||||
pub use bigint::BigInt;
|
||||
pub use bigint::IntoBigInt;
|
||||
pub use bigint::Sign;
|
||||
pub use bigint::ToBigInt;
|
||||
pub use crate::bigint::negate_sign;
|
||||
pub use crate::bigint::BigInt;
|
||||
pub use crate::bigint::IntoBigInt;
|
||||
pub use crate::bigint::Sign;
|
||||
pub use crate::bigint::ToBigInt;
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
pub use bigrand::{RandBigInt, RandomBits, UniformBigInt, UniformBigUint};
|
||||
pub use crate::bigrand::{RandBigInt, RandomBits, UniformBigInt, UniformBigUint};
|
||||
|
||||
#[cfg(feature = "prime")]
|
||||
pub use bigrand::RandPrime;
|
||||
|
@ -4,8 +4,8 @@ use num_traits::{One, Zero};
|
||||
use core::ops::Shl;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use big_digit::{self, BigDigit, DoubleBigDigit, SignedDoubleBigDigit};
|
||||
use biguint::BigUint;
|
||||
use crate::big_digit::{self, BigDigit, DoubleBigDigit, SignedDoubleBigDigit};
|
||||
use crate::biguint::BigUint;
|
||||
|
||||
struct MontyReducer {
|
||||
n0inv: BigDigit,
|
||||
|
@ -4,9 +4,9 @@ extern crate num_traits;
|
||||
#[cfg(feature = "rand")]
|
||||
extern crate rand;
|
||||
|
||||
use num_bigint::BigUint;
|
||||
use num_bigint::Sign::{Minus, NoSign, Plus};
|
||||
use num_bigint::{BigInt, ToBigInt};
|
||||
use crate::num_bigint::BigUint;
|
||||
use crate::num_bigint::Sign::{Minus, NoSign, Plus};
|
||||
use crate::num_bigint::{BigInt, ToBigInt};
|
||||
|
||||
use std::cmp::Ordering::{Equal, Greater, Less};
|
||||
use std::collections::hash_map::RandomState;
|
||||
@ -24,7 +24,7 @@ use num_traits::float::FloatCore;
|
||||
use num_traits::{FromPrimitive, Num, One, Pow, Signed, ToPrimitive, Zero};
|
||||
|
||||
mod consts;
|
||||
use consts::*;
|
||||
use crate::consts::*;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
@ -1,7 +1,7 @@
|
||||
extern crate num_bigint_dig as num_bigint;
|
||||
extern crate num_traits;
|
||||
|
||||
use num_bigint::{BigInt, Sign, ToBigInt};
|
||||
use crate::num_bigint::{BigInt, Sign, ToBigInt};
|
||||
use num_traits::ToPrimitive;
|
||||
use std::{i32, i64, u32};
|
||||
|
||||
@ -11,7 +11,7 @@ enum ValueVec {
|
||||
M(&'static [u32]),
|
||||
}
|
||||
|
||||
use ValueVec::*;
|
||||
use crate::ValueVec::*;
|
||||
|
||||
impl ToBigInt for ValueVec {
|
||||
fn to_bigint(&self) -> Option<BigInt> {
|
||||
|
@ -1,14 +1,14 @@
|
||||
extern crate num_bigint_dig as num_bigint;
|
||||
extern crate num_traits;
|
||||
|
||||
use num_bigint::BigInt;
|
||||
use num_bigint::Sign::Plus;
|
||||
use crate::num_bigint::BigInt;
|
||||
use crate::num_bigint::Sign::Plus;
|
||||
use num_traits::{Signed, ToPrimitive, Zero};
|
||||
|
||||
use std::ops::Neg;
|
||||
|
||||
mod consts;
|
||||
use consts::*;
|
||||
use crate::consts::*;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
@ -3,9 +3,9 @@ extern crate num_integer;
|
||||
extern crate num_traits;
|
||||
extern crate smallvec;
|
||||
|
||||
use num_bigint::Sign::Plus;
|
||||
use num_bigint::{BigInt, ToBigInt};
|
||||
use num_bigint::{BigUint, ToBigUint};
|
||||
use crate::num_bigint::Sign::Plus;
|
||||
use crate::num_bigint::{BigInt, ToBigInt};
|
||||
use crate::num_bigint::{BigUint, ToBigUint};
|
||||
use num_integer::Integer;
|
||||
|
||||
use std::cmp::Ordering::{Equal, Greater, Less};
|
||||
@ -27,7 +27,7 @@ use num_traits::{
|
||||
use num_traits::float::FloatCore;
|
||||
|
||||
mod consts;
|
||||
use consts::*;
|
||||
use crate::consts::*;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
@ -143,7 +143,7 @@ fn hash<T: Hash>(x: &T) -> u64 {
|
||||
|
||||
#[test]
|
||||
fn test_hash() {
|
||||
use hash;
|
||||
use crate::hash;
|
||||
|
||||
let a = BigUint::new(vec![]);
|
||||
let b = BigUint::new(vec![0]);
|
||||
|
@ -1,11 +1,11 @@
|
||||
extern crate num_bigint_dig as num_bigint;
|
||||
extern crate num_traits;
|
||||
|
||||
use num_bigint::BigUint;
|
||||
use crate::num_bigint::BigUint;
|
||||
use num_traits::{ToPrimitive, Zero};
|
||||
|
||||
mod consts;
|
||||
use consts::*;
|
||||
use crate::consts::*;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
@ -57,7 +57,7 @@ static BIG_R: &'static str = "\
|
||||
109c4735_6e7db425_7b5d74c7_0b709508";
|
||||
|
||||
mod biguint {
|
||||
use num_bigint::BigUint;
|
||||
use crate::num_bigint::BigUint;
|
||||
use num_integer::Integer;
|
||||
use num_traits::Num;
|
||||
|
||||
@ -100,7 +100,7 @@ mod biguint {
|
||||
}
|
||||
|
||||
mod bigint {
|
||||
use num_bigint::BigInt;
|
||||
use crate::num_bigint::BigInt;
|
||||
use num_integer::Integer;
|
||||
use num_traits::{Num, One, Signed, Zero};
|
||||
|
||||
|
@ -8,7 +8,7 @@ extern crate rand_isaac;
|
||||
extern crate rand_xorshift;
|
||||
|
||||
mod biguint {
|
||||
use num_bigint::{BigUint, RandBigInt, RandomBits};
|
||||
use crate::num_bigint::{BigUint, RandBigInt, RandomBits};
|
||||
use num_traits::Zero;
|
||||
use rand::distributions::Uniform;
|
||||
use rand::{Rng, SeedableRng};
|
||||
@ -222,7 +222,7 @@ mod biguint {
|
||||
}
|
||||
|
||||
mod bigint {
|
||||
use num_bigint::{BigInt, RandBigInt, RandomBits};
|
||||
use crate::num_bigint::{BigInt, RandBigInt, RandomBits};
|
||||
use num_traits::Zero;
|
||||
use rand::distributions::Uniform;
|
||||
use rand::{Rng, SeedableRng};
|
||||
|
@ -6,7 +6,7 @@ extern crate num_traits;
|
||||
extern crate rand;
|
||||
|
||||
mod biguint {
|
||||
use num_bigint::BigUint;
|
||||
use crate::num_bigint::BigUint;
|
||||
use num_traits::{One, Pow, Zero};
|
||||
use std::{i32, u32};
|
||||
|
||||
@ -115,7 +115,7 @@ mod biguint {
|
||||
rand::rngs::StdRng::seed_from_u64(4)
|
||||
}
|
||||
|
||||
use num_bigint::RandBigInt;
|
||||
use crate::num_bigint::RandBigInt;
|
||||
use rand::distributions::Uniform;
|
||||
use rand::Rng;
|
||||
|
||||
@ -150,7 +150,7 @@ mod biguint {
|
||||
}
|
||||
|
||||
mod bigint {
|
||||
use num_bigint::BigInt;
|
||||
use crate::num_bigint::BigInt;
|
||||
use num_traits::{Pow, Signed};
|
||||
|
||||
fn check(x: i64, n: u32) {
|
||||
|
@ -10,7 +10,7 @@ extern crate num_bigint_dig as num_bigint;
|
||||
extern crate num_traits;
|
||||
extern crate serde_test;
|
||||
|
||||
use num_bigint::{BigInt, BigUint};
|
||||
use crate::num_bigint::{BigInt, BigUint};
|
||||
use num_traits::{One, Zero};
|
||||
use serde_test::{assert_tokens, Token};
|
||||
|
||||
|
@ -4,7 +4,7 @@ extern crate num_bigint_dig as num_bigint;
|
||||
extern crate num_traits;
|
||||
extern crate rand;
|
||||
|
||||
use num_bigint::RandBigInt;
|
||||
use crate::num_bigint::RandBigInt;
|
||||
use num_traits::Zero;
|
||||
use rand::prelude::*;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user