diff --git a/.travis.yml b/.travis.yml index bdef7bf..f9d09e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: rust rust: - - 1.36.0 + - 1.56.0 - stable - beta - nightly diff --git a/Cargo.toml b/Cargo.toml index bed64f5..f46cae7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/README.md b/README.md index 503b18e..6011ab6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![crate](https://img.shields.io/crates/v/num-bigint-dig.svg)](https://crates.io/crates/num-bigint-dig) [![documentation](https://docs.rs/num-bigint-dig/badge.svg)](https://docs.rs/num-bigint-dig) -![minimum rustc 1.36](https://img.shields.io/badge/rustc-1.36+-red.svg) +![minimum rustc 1.56](https://img.shields.io/badge/rustc-1.56+-red.svg) [![Travis status](https://travis-ci.org/dignifiedquire/num-bigint.svg?branch=master)](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`] | diff --git a/src/algorithms/gcd.rs b/src/algorithms/gcd.rs index a4ae75a..cf6d724 100644 --- a/src/algorithms/gcd.rs +++ b/src/algorithms/gcd.rs @@ -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; diff --git a/src/algorithms/jacobi.rs b/src/algorithms/jacobi.rs index 75f3c7c..327d11a 100644 --- a/src/algorithms/jacobi.rs +++ b/src/algorithms/jacobi.rs @@ -1,4 +1,4 @@ -use integer::Integer; +use crate::integer::Integer; use num_traits::{One, Signed, Zero}; use crate::BigInt; diff --git a/src/algorithms/mod_inverse.rs b/src/algorithms/mod_inverse.rs index b028133..775504f 100644 --- a/src/algorithms/mod_inverse.rs +++ b/src/algorithms/mod_inverse.rs @@ -28,7 +28,7 @@ pub fn mod_inverse(g: Cow, n: Cow) -> Option { mod tests { use super::*; - use integer::Integer; + use crate::integer::Integer; use num_traits::FromPrimitive; use crate::traits::ModInverse; diff --git a/src/bigint.rs b/src/bigint.rs index 9252464..218ffad 100644 --- a/src/bigint.rs +++ b/src/bigint.rs @@ -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; diff --git a/src/bigrand.rs b/src/bigrand.rs index c0c155a..e71bd0d 100644 --- a/src/bigrand.rs +++ b/src/bigrand.rs @@ -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(low_b: B1, high_b: B2) -> Self where diff --git a/src/biguint.rs b/src/biguint.rs index c89f90f..521fb55 100644 --- a/src/biguint.rs +++ b/src/biguint.rs @@ -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)] diff --git a/src/lib.rs b/src/lib.rs index a9efa60..550a22b 100644 --- a/src/lib.rs +++ b/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; diff --git a/src/monty.rs b/src/monty.rs index 3066ace..e63324c 100644 --- a/src/monty.rs +++ b/src/monty.rs @@ -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, diff --git a/tests/bigint.rs b/tests/bigint.rs index 550b506..2228883 100644 --- a/tests/bigint.rs +++ b/tests/bigint.rs @@ -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; diff --git a/tests/bigint_bitwise.rs b/tests/bigint_bitwise.rs index bec4aa0..82b9fea 100644 --- a/tests/bigint_bitwise.rs +++ b/tests/bigint_bitwise.rs @@ -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 { diff --git a/tests/bigint_scalar.rs b/tests/bigint_scalar.rs index 86fd449..f0f32bb 100644 --- a/tests/bigint_scalar.rs +++ b/tests/bigint_scalar.rs @@ -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; diff --git a/tests/biguint.rs b/tests/biguint.rs index 41c5c3b..f52ee22 100644 --- a/tests/biguint.rs +++ b/tests/biguint.rs @@ -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(x: &T) -> u64 { #[test] fn test_hash() { - use hash; + use crate::hash; let a = BigUint::new(vec![]); let b = BigUint::new(vec![0]); diff --git a/tests/biguint_scalar.rs b/tests/biguint_scalar.rs index 1e8e899..e25c208 100644 --- a/tests/biguint_scalar.rs +++ b/tests/biguint_scalar.rs @@ -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; diff --git a/tests/modpow.rs b/tests/modpow.rs index d26b1e6..5479906 100644 --- a/tests/modpow.rs +++ b/tests/modpow.rs @@ -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}; diff --git a/tests/rand.rs b/tests/rand.rs index 3c692e5..be6123a 100644 --- a/tests/rand.rs +++ b/tests/rand.rs @@ -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}; diff --git a/tests/roots.rs b/tests/roots.rs index d22772e..7be9703 100644 --- a/tests/roots.rs +++ b/tests/roots.rs @@ -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) { diff --git a/tests/serde.rs b/tests/serde.rs index 11fa335..8b54658 100644 --- a/tests/serde.rs +++ b/tests/serde.rs @@ -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}; diff --git a/tests/torture.rs b/tests/torture.rs index b6f6f5b..a38dbf8 100644 --- a/tests/torture.rs +++ b/tests/torture.rs @@ -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::*;