Skip to content

Commit 7d5d3f0

Browse files
bors[bot]cuviper
andauthored
Merge #80
80: Reorganize num-bigint features r=cuviper a=cuviper - `num-bigint` was already an implicit cargo feature for the optional dependency, so make that the primary enabler, removing `bigint`. - `bigint-std` is now `num-bigint-std`, to enable `num-bigint/std`. Co-authored-by: Josh Stone <cuviper@gmail.com>
2 parents 3605565 + b2fe4c5 commit 7d5d3f0

File tree

5 files changed

+31
-34
lines changed

5 files changed

+31
-34
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
uses: actions-rs/cargo@v1
5454
with:
5555
command: build
56-
args: --target thumbv6m-none-eabi --no-default-features --features "bigint serde"
56+
args: --target thumbv6m-none-eabi --no-default-features --features "num-bigint serde"
5757

5858
# try a target that doesn't have std at all, nor alloc
5959
no_std_131:

Cargo.toml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,19 @@ categories = ["algorithms", "data-structures", "science", "no-std"]
88
license = "MIT/Apache-2.0"
99
name = "num-rational"
1010
repository = "https://github.com/rust-num/num-rational"
11-
version = "0.3.0-pre"
11+
version = "0.3.0"
1212
readme = "README.md"
1313
exclude = ["/bors.toml", "/ci/*", "/.github/*"]
14-
publish = false
1514
edition = "2018"
1615

1716
[package.metadata.docs.rs]
18-
features = ["std", "bigint-std", "serde"]
17+
features = ["std", "num-bigint-std", "serde"]
1918

2019
[dependencies]
2120

2221
[dependencies.num-bigint]
2322
optional = true
24-
version = "0.3.0-pre"
25-
git = "https://github.com/rust-num/num-bigint"
23+
version = "0.3.0"
2624
default-features = false
2725

2826
[dependencies.num-integer]
@@ -41,10 +39,9 @@ version = "1.0.0"
4139
default-features = false
4240

4341
[features]
44-
default = ["bigint-std", "std"]
42+
default = ["num-bigint-std", "std"]
4543
std = ["num-integer/std", "num-traits/std"]
46-
bigint = ["num-bigint"]
47-
bigint-std = ["bigint", "num-bigint/std"]
44+
num-bigint-std = ["num-bigint/std"]
4845

4946
[build-dependencies]
5047
autocfg = "1.0.0"

ci/test_full.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ if ! check_version $MSRV ; then
2727
exit 1
2828
fi
2929

30-
STD_FEATURES=(bigint-std serde)
30+
STD_FEATURES=(num-bigint-std serde)
3131
NO_STD_FEATURES=(serde)
32-
check_version 1.36 && NO_STD_FEATURES+=(bigint)
32+
check_version 1.36 && NO_STD_FEATURES+=(num-bigint)
3333
echo "Testing supported features: ${STD_FEATURES[*]}"
3434
echo " no_std supported features: ${NO_STD_FEATURES[*]}"
3535

src/lib.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use core::str::FromStr;
3333
#[cfg(feature = "std")]
3434
use std::error::Error;
3535

36-
#[cfg(feature = "bigint")]
36+
#[cfg(feature = "num-bigint")]
3737
use num_bigint::{BigInt, BigUint, Sign, ToBigInt};
3838

3939
use num_integer::Integer;
@@ -63,7 +63,7 @@ pub type Rational32 = Ratio<i32>;
6363
/// Alias for a `Ratio` of 64-bit-sized integers.
6464
pub type Rational64 = Ratio<i64>;
6565

66-
#[cfg(feature = "bigint")]
66+
#[cfg(feature = "num-bigint")]
6767
/// Alias for arbitrary precision rationals.
6868
pub type BigRational = Ratio<BigInt>;
6969

@@ -257,7 +257,7 @@ impl<T: Clone + Integer> Ratio<T> {
257257
}
258258
}
259259

260-
#[cfg(feature = "bigint")]
260+
#[cfg(feature = "num-bigint")]
261261
impl Ratio<BigInt> {
262262
/// Converts a float into a rational number.
263263
pub fn from_float<T: FloatCore>(f: T) -> Option<BigRational> {
@@ -1173,7 +1173,7 @@ impl RatioErrorKind {
11731173
}
11741174
}
11751175

1176-
#[cfg(feature = "bigint")]
1176+
#[cfg(feature = "num-bigint")]
11771177
impl FromPrimitive for Ratio<BigInt> {
11781178
fn from_i64(n: i64) -> Option<Self> {
11791179
Some(Ratio::from_integer(n.into()))
@@ -1361,7 +1361,7 @@ where
13611361
Some(Ratio::new(n1, d1))
13621362
}
13631363

1364-
#[cfg(not(feature = "bigint"))]
1364+
#[cfg(not(feature = "num-bigint"))]
13651365
macro_rules! to_primitive_small {
13661366
($($type_name:ty)*) => ($(
13671367
impl ToPrimitive for Ratio<$type_name> {
@@ -1388,13 +1388,13 @@ macro_rules! to_primitive_small {
13881388
)*)
13891389
}
13901390

1391-
#[cfg(not(feature = "bigint"))]
1391+
#[cfg(not(feature = "num-bigint"))]
13921392
to_primitive_small!(u8 i8 u16 i16 u32 i32);
13931393

1394-
#[cfg(all(target_pointer_width = "32", not(feature = "bigint")))]
1394+
#[cfg(all(target_pointer_width = "32", not(feature = "num-bigint")))]
13951395
to_primitive_small!(usize isize);
13961396

1397-
#[cfg(not(feature = "bigint"))]
1397+
#[cfg(not(feature = "num-bigint"))]
13981398
macro_rules! to_primitive_64 {
13991399
($($type_name:ty)*) => ($(
14001400
impl ToPrimitive for Ratio<$type_name> {
@@ -1424,13 +1424,13 @@ macro_rules! to_primitive_64 {
14241424
)*)
14251425
}
14261426

1427-
#[cfg(not(feature = "bigint"))]
1427+
#[cfg(not(feature = "num-bigint"))]
14281428
to_primitive_64!(u64 i64);
14291429

1430-
#[cfg(all(target_pointer_width = "64", not(feature = "bigint")))]
1430+
#[cfg(all(target_pointer_width = "64", not(feature = "num-bigint")))]
14311431
to_primitive_64!(usize isize);
14321432

1433-
#[cfg(feature = "bigint")]
1433+
#[cfg(feature = "num-bigint")]
14341434
impl<T: Clone + Integer + ToPrimitive + ToBigInt> ToPrimitive for Ratio<T> {
14351435
fn to_i64(&self) -> Option<i64> {
14361436
self.to_integer().to_i64()
@@ -1467,7 +1467,7 @@ trait Bits {
14671467
fn bits(&self) -> u64;
14681468
}
14691469

1470-
#[cfg(feature = "bigint")]
1470+
#[cfg(feature = "num-bigint")]
14711471
impl Bits for BigInt {
14721472
fn bits(&self) -> u64 {
14731473
self.bits()
@@ -1590,9 +1590,9 @@ fn hash<T: Hash>(x: &T) -> u64 {
15901590

15911591
#[cfg(test)]
15921592
mod test {
1593-
#[cfg(all(feature = "bigint"))]
1593+
#[cfg(all(feature = "num-bigint"))]
15941594
use super::BigInt;
1595-
#[cfg(feature = "bigint")]
1595+
#[cfg(feature = "num-bigint")]
15961596
use super::BigRational;
15971597
use super::{Ratio, Rational, Rational64};
15981598

@@ -1676,14 +1676,14 @@ mod test {
16761676
denom: 1,
16771677
};
16781678

1679-
#[cfg(feature = "bigint")]
1679+
#[cfg(feature = "num-bigint")]
16801680
pub fn to_big(n: Rational) -> BigRational {
16811681
Ratio::new(
16821682
FromPrimitive::from_isize(n.numer).unwrap(),
16831683
FromPrimitive::from_isize(n.denom).unwrap(),
16841684
)
16851685
}
1686-
#[cfg(not(feature = "bigint"))]
1686+
#[cfg(not(feature = "num-bigint"))]
16871687
pub fn to_big(n: Rational) -> Rational {
16881688
Ratio::new(
16891689
FromPrimitive::from_isize(n.numer).unwrap(),
@@ -2607,11 +2607,11 @@ mod test {
26072607
assert_eq!(Pow::pow(r, &e), expected);
26082608
assert_eq!(Pow::pow(&r, e), expected);
26092609
assert_eq!(Pow::pow(&r, &e), expected);
2610-
#[cfg(feature = "bigint")]
2610+
#[cfg(feature = "num-bigint")]
26112611
test_big(r, e, expected);
26122612
}
26132613

2614-
#[cfg(feature = "bigint")]
2614+
#[cfg(feature = "num-bigint")]
26152615
fn test_big(r: Rational, e: i32, expected: Rational) {
26162616
let r = BigRational::new_raw(r.numer.into(), r.denom.into());
26172617
let expected = BigRational::new_raw(expected.numer.into(), expected.denom.into());
@@ -2662,7 +2662,7 @@ mod test {
26622662
}
26632663
}
26642664

2665-
#[cfg(feature = "bigint")]
2665+
#[cfg(feature = "num-bigint")]
26662666
#[test]
26672667
fn test_from_float() {
26682668
use num_traits::float::FloatCore;
@@ -2709,7 +2709,7 @@ mod test {
27092709
);
27102710
}
27112711

2712-
#[cfg(feature = "bigint")]
2712+
#[cfg(feature = "num-bigint")]
27132713
#[test]
27142714
fn test_from_float_fail() {
27152715
use core::{f32, f64};
@@ -2870,7 +2870,7 @@ mod test {
28702870
}
28712871

28722872
#[test]
2873-
#[cfg(feature = "bigint")]
2873+
#[cfg(feature = "num-bigint")]
28742874
fn test_ratio_to_i128() {
28752875
assert_eq!(
28762876
1i128 << 70,
@@ -2881,7 +2881,7 @@ mod test {
28812881
}
28822882

28832883
#[test]
2884-
#[cfg(feature = "bigint")]
2884+
#[cfg(feature = "num-bigint")]
28852885
fn test_big_ratio_to_f64() {
28862886
assert_eq!(
28872887
BigRational::new(

src/pow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pow_signed_impl!(i64, u64);
112112
pow_signed_impl!(i128, u128);
113113
pow_signed_impl!(isize, usize);
114114

115-
#[cfg(feature = "bigint")]
115+
#[cfg(feature = "num-bigint")]
116116
mod bigint {
117117
use super::*;
118118
use num_bigint::{BigInt, BigUint, Sign};

0 commit comments

Comments
 (0)