Skip to content

Commit 5d6f64d

Browse files
bors[bot]cuviper
andauthored
Merge #384
384: Upgrade to 2018 edition and MSRV 1.31 r=cuviper a=cuviper Co-authored-by: Josh Stone <[email protected]>
2 parents ea9ba9e + dc66fd6 commit 5d6f64d

6 files changed

Lines changed: 63 additions & 59 deletions

File tree

‎.travis.yml‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
language: rust
22
sudo: false
33
rust:
4-
- 1.15.0
5-
- 1.22.0 # rand
6-
- 1.26.0 # has_i128
74
- 1.31.0 # 2018!
5+
- 1.32.0 # rand
6+
- 1.36.0 # alloc
87
- stable
98
- beta
109
- nightly
@@ -13,10 +12,18 @@ script:
1312
- ./ci/test_full.sh
1413
matrix:
1514
include:
16-
# try a target that doesn't have std at all
17-
- name: "no_std"
15+
# try a target that doesn't have std at all, but does have alloc
16+
- name: "alloc"
1817
rust: stable
1918
env: TARGET=thumbv6m-none-eabi
19+
before_script:
20+
- rustup target add $TARGET
21+
script:
22+
- cargo build --verbose --target $TARGET --no-default-features --features "alloc serde rand"
23+
# try a target that doesn't have std at all, nor alloc
24+
- name: "no_std"
25+
rust: 1.31.0
26+
env: TARGET=thumbv6m-none-eabi
2027
before_script:
2128
- rustup target add $TARGET
2229
script:

‎Cargo.toml‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ version = "0.3.0-pre"
1212
readme = "README.md"
1313
exclude = ["/ci/*", "/.travis.yml", "/bors.toml"]
1414
publish = false
15+
edition = "2018"
1516

1617
[package.metadata.docs.rs]
1718
features = ["std", "serde", "rand"]
@@ -22,7 +23,7 @@ travis-ci = { repository = "rust-num/num" }
2223
[dependencies]
2324

2425
[dependencies.num-bigint]
25-
optional = true # needs std
26+
optional = true # needs std until Rust 1.36
2627
version = "0.3.0-pre"
2728
git = "https://github.com/rust-num/num-bigint"
2829
default-features = false
@@ -35,10 +36,12 @@ default-features = false
3536
[dependencies.num-integer]
3637
version = "0.1.42"
3738
default-features = false
39+
features = ["i128"]
3840

3941
[dependencies.num-iter]
4042
version = "0.1.40"
4143
default-features = false
44+
features = ["i128"]
4245

4346
[dependencies.num-rational]
4447
version = "0.3.0-pre"
@@ -48,6 +51,7 @@ default-features = false
4851
[dependencies.num-traits]
4952
version = "0.2.11"
5053
default-features = false
54+
features = ["i128"]
5155

5256
[dev-dependencies]
5357

@@ -59,18 +63,11 @@ std = [
5963
"num-complex/std",
6064
"num-integer/std",
6165
"num-iter/std",
62-
"num-rational/std", "num-rational/bigint",
66+
"num-rational/std", "num-rational/bigint-std",
6367
"num-traits/std",
6468
]
6569

66-
i128 = [
67-
"num-bigint/i128",
68-
"num-complex/i128",
69-
"num-integer/i128",
70-
"num-iter/i128",
71-
"num-rational/i128",
72-
"num-traits/i128",
73-
]
70+
alloc = ["num-bigint", "num-rational/bigint"]
7471

7572
rand = [
7673
"num-bigint/rand",

‎README.md‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![crate](https://img.shields.io/crates/v/num.svg)](https://crates.io/crates/num)
44
[![documentation](https://docs.rs/num/badge.svg)](https://docs.rs/num)
5-
![minimum rustc 1.15](https://img.shields.io/badge/rustc-1.15+-red.svg)
5+
![minimum rustc 1.31](https://img.shields.io/badge/rustc-1.31+-red.svg)
66
[![Travis status](https://travis-ci.org/rust-num/num.svg?branch=master)](https://travis-ci.org/rust-num/num)
77

88
A collection of numeric types and traits for Rust.
@@ -32,13 +32,7 @@ Add this to your `Cargo.toml`:
3232

3333
```toml
3434
[dependencies]
35-
num = "0.2"
36-
```
37-
38-
and this to your crate root:
39-
40-
```rust
41-
extern crate num;
35+
num = "0.3"
4236
```
4337

4438
## Features
@@ -48,16 +42,13 @@ the default `std` feature. Use this in `Cargo.toml`:
4842

4943
```toml
5044
[dependencies.num]
51-
version = "0.2"
45+
version = "0.3"
5246
default-features = false
5347
```
5448

55-
The `num-bigint` crate is only available when `std` is enabled, and the other
56-
sub-crates may have limited functionality when used without `std`.
57-
58-
Implementations for `i128` and `u128` are only available with Rust 1.26 and
59-
later. The build script automatically detects this, but you can make it
60-
mandatory by enabling the `i128` crate feature.
49+
The `num-bigint` crate requires the `std` feature, or the `alloc` feature may
50+
be used instead with Rust 1.36 and later. Other sub-crates may also have
51+
limited functionality when used without `std`.
6152

6253
The `rand` feature enables randomization traits in `num-bigint` and
6354
`num-complex`.
@@ -75,7 +66,7 @@ Release notes are available in [RELEASES.md](RELEASES.md).
7566

7667
## Compatibility
7768

78-
The `num` crate as a whole is tested for rustc 1.15 and greater.
69+
The `num` crate as a whole is tested for rustc 1.31 and greater.
7970

8071
The `num-traits`, `num-integer`, and `num-iter` crates are individually tested
8172
for rustc 1.8 and greater, if you require such older compatibility.

‎ci/rustup.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
set -ex
66

77
export TRAVIS_RUST_VERSION
8-
for TRAVIS_RUST_VERSION in 1.15.0 1.22.0 1.26.0 stable beta nightly; do
8+
for TRAVIS_RUST_VERSION in 1.31.0 1.32.0 1.36.0 stable beta nightly; do
99
run="rustup run $TRAVIS_RUST_VERSION"
1010
$run cargo build --verbose
1111
$run $PWD/ci/test_full.sh

‎ci/test_full.sh‎

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ set -ex
44

55
echo Testing num on rustc ${TRAVIS_RUST_VERSION}
66

7-
FEATURES="serde"
8-
if [[ "$TRAVIS_RUST_VERSION" =~ ^(nightly|beta|stable|1.26.0|1.22.0)$ ]]; then
9-
FEATURES="$FEATURES rand"
10-
fi
11-
if [[ "$TRAVIS_RUST_VERSION" =~ ^(nightly|beta|stable|1.26.0)$ ]]; then
12-
FEATURES="$FEATURES i128"
13-
fi
7+
case "$TRAVIS_RUST_VERSION" in
8+
1.31.*) STD_FEATURES="serde" ;;
9+
*) STD_FEATURES="serde rand" ;;
10+
esac
11+
12+
case "$TRAVIS_RUST_VERSION" in
13+
1.3[1-5].*) ;;
14+
*) ALLOC_FEATURES="serde rand" ;;
15+
esac
1416

1517
# num should build and test everywhere.
1618
cargo build --verbose
@@ -22,11 +24,27 @@ cargo test --no-default-features
2224

2325
# Each isolated feature should also work everywhere.
2426
# (but still with "std", else bigint breaks)
25-
for feature in $FEATURES; do
27+
for feature in $STD_FEATURES; do
2628
cargo build --verbose --no-default-features --features="std $feature"
2729
cargo test --verbose --no-default-features --features="std $feature"
2830
done
2931

3032
# test all supported features together
31-
cargo build --features="std $FEATURES"
32-
cargo test --features="std $FEATURES"
33+
cargo build --features="std $STD_FEATURES"
34+
cargo test --features="std $STD_FEATURES"
35+
36+
if test -n "${ALLOC_FEATURES:+true}"; then
37+
# It should build with minimal features too.
38+
cargo build --no-default-features --features="alloc"
39+
cargo test --no-default-features --features="alloc"
40+
41+
# Each isolated feature should also work everywhere.
42+
for feature in $ALLOC_FEATURES; do
43+
cargo build --verbose --no-default-features --features="alloc $feature"
44+
cargo test --verbose --no-default-features --features="alloc $feature"
45+
done
46+
47+
# test all supported features together
48+
cargo build --no-default-features --features="alloc $ALLOC_FEATURES"
49+
cargo test --no-default-features --features="alloc $ALLOC_FEATURES"
50+
fi

‎src/lib.rs‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
//! approximate a square root to arbitrary precision:
2121
//!
2222
//! ```
23-
//! extern crate num;
24-
//! # #[cfg(feature = "std")]
23+
//! # #[cfg(any(feature = "alloc", feature = "std"))]
2524
//! # mod test {
2625
//!
2726
//! use num::FromPrimitive;
@@ -41,9 +40,9 @@
4140
//! approx
4241
//! }
4342
//! # }
44-
//! # #[cfg(not(feature = "std"))]
43+
//! # #[cfg(not(any(feature = "alloc", feature = "std")))]
4544
//! # mod test { pub fn approx_sqrt(n: u64, _: usize) -> u64 { n } }
46-
//! # use test::approx_sqrt;
45+
//! # use crate::test::approx_sqrt;
4746
//!
4847
//! fn main() {
4948
//! println!("{}", approx_sqrt(10, 4)); // prints 4057691201/1283082416
@@ -55,25 +54,17 @@
5554
//!
5655
//! ## Compatibility
5756
//!
58-
//! The `num` crate is tested for rustc 1.15 and greater.
57+
//! The `num` crate is tested for rustc 1.31 and greater.
5958
60-
#![doc(html_root_url = "https://docs.rs/num/0.2")]
59+
#![doc(html_root_url = "https://docs.rs/num/0.3")]
6160
#![no_std]
6261

63-
#[cfg(feature = "std")]
64-
extern crate num_bigint;
65-
extern crate num_complex;
66-
extern crate num_integer;
67-
extern crate num_iter;
68-
extern crate num_rational;
69-
extern crate num_traits;
70-
71-
#[cfg(feature = "std")]
62+
#[cfg(any(feature = "alloc", feature = "std"))]
7263
pub use num_bigint::{BigInt, BigUint};
7364

7465
pub use num_complex::Complex;
7566

76-
#[cfg(feature = "std")]
67+
#[cfg(any(feature = "alloc", feature = "std"))]
7768
pub use num_rational::BigRational;
7869
pub use num_rational::Rational;
7970

@@ -89,7 +80,7 @@ pub use num_traits::{
8980
Signed, ToPrimitive, Unsigned, Zero,
9081
};
9182

92-
#[cfg(feature = "std")]
83+
#[cfg(any(feature = "alloc", feature = "std"))]
9384
pub mod bigint {
9485
pub use num_bigint::*;
9586
}

0 commit comments

Comments
 (0)