Skip to content

Commit

Permalink
Merge #384
Browse files Browse the repository at this point in the history
384: Upgrade to 2018 edition and MSRV 1.31 r=cuviper a=cuviper



Co-authored-by: Josh Stone <cuviper@gmail.com>
  • Loading branch information
bors[bot] and cuviper committed Jan 21, 2020
2 parents ea9ba9e + dc66fd6 commit 5d6f64d
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 59 deletions.
17 changes: 12 additions & 5 deletions .travis.yml
@@ -1,10 +1,9 @@
language: rust
sudo: false
rust:
- 1.15.0
- 1.22.0 # rand
- 1.26.0 # has_i128
- 1.31.0 # 2018!
- 1.32.0 # rand
- 1.36.0 # alloc
- stable
- beta
- nightly
Expand All @@ -13,10 +12,18 @@ script:
- ./ci/test_full.sh
matrix:
include:
# try a target that doesn't have std at all
- name: "no_std"
# try a target that doesn't have std at all, but does have alloc
- name: "alloc"
rust: stable
env: TARGET=thumbv6m-none-eabi
before_script:
- rustup target add $TARGET
script:
- cargo build --verbose --target $TARGET --no-default-features --features "alloc serde rand"
# try a target that doesn't have std at all, nor alloc
- name: "no_std"
rust: 1.31.0
env: TARGET=thumbv6m-none-eabi
before_script:
- rustup target add $TARGET
script:
Expand Down
17 changes: 7 additions & 10 deletions Cargo.toml
Expand Up @@ -12,6 +12,7 @@ version = "0.3.0-pre"
readme = "README.md"
exclude = ["/ci/*", "/.travis.yml", "/bors.toml"]
publish = false
edition = "2018"

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

[dependencies.num-bigint]
optional = true # needs std
optional = true # needs std until Rust 1.36
version = "0.3.0-pre"
git = "https://github.com/rust-num/num-bigint"
default-features = false
Expand All @@ -35,10 +36,12 @@ default-features = false
[dependencies.num-integer]
version = "0.1.42"
default-features = false
features = ["i128"]

[dependencies.num-iter]
version = "0.1.40"
default-features = false
features = ["i128"]

[dependencies.num-rational]
version = "0.3.0-pre"
Expand All @@ -48,6 +51,7 @@ default-features = false
[dependencies.num-traits]
version = "0.2.11"
default-features = false
features = ["i128"]

[dev-dependencies]

Expand All @@ -59,18 +63,11 @@ std = [
"num-complex/std",
"num-integer/std",
"num-iter/std",
"num-rational/std", "num-rational/bigint",
"num-rational/std", "num-rational/bigint-std",
"num-traits/std",
]

i128 = [
"num-bigint/i128",
"num-complex/i128",
"num-integer/i128",
"num-iter/i128",
"num-rational/i128",
"num-traits/i128",
]
alloc = ["num-bigint", "num-rational/bigint"]

rand = [
"num-bigint/rand",
Expand Down
23 changes: 7 additions & 16 deletions README.md
Expand Up @@ -2,7 +2,7 @@

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

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

```toml
[dependencies]
num = "0.2"
```

and this to your crate root:

```rust
extern crate num;
num = "0.3"
```

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

```toml
[dependencies.num]
version = "0.2"
version = "0.3"
default-features = false
```

The `num-bigint` crate is only available when `std` is enabled, and the other
sub-crates may have limited functionality when used without `std`.

Implementations for `i128` and `u128` are only available with Rust 1.26 and
later. The build script automatically detects this, but you can make it
mandatory by enabling the `i128` crate feature.
The `num-bigint` crate requires the `std` feature, or the `alloc` feature may
be used instead with Rust 1.36 and later. Other sub-crates may also have
limited functionality when used without `std`.

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

## Compatibility

The `num` crate as a whole is tested for rustc 1.15 and greater.
The `num` crate as a whole is tested for rustc 1.31 and greater.

The `num-traits`, `num-integer`, and `num-iter` crates are individually tested
for rustc 1.8 and greater, if you require such older compatibility.
Expand Down
2 changes: 1 addition & 1 deletion ci/rustup.sh
Expand Up @@ -5,7 +5,7 @@
set -ex

export TRAVIS_RUST_VERSION
for TRAVIS_RUST_VERSION in 1.15.0 1.22.0 1.26.0 stable beta nightly; do
for TRAVIS_RUST_VERSION in 1.31.0 1.32.0 1.36.0 stable beta nightly; do
run="rustup run $TRAVIS_RUST_VERSION"
$run cargo build --verbose
$run $PWD/ci/test_full.sh
Expand Down
38 changes: 28 additions & 10 deletions ci/test_full.sh
Expand Up @@ -4,13 +4,15 @@ set -ex

echo Testing num on rustc ${TRAVIS_RUST_VERSION}

FEATURES="serde"
if [[ "$TRAVIS_RUST_VERSION" =~ ^(nightly|beta|stable|1.26.0|1.22.0)$ ]]; then
FEATURES="$FEATURES rand"
fi
if [[ "$TRAVIS_RUST_VERSION" =~ ^(nightly|beta|stable|1.26.0)$ ]]; then
FEATURES="$FEATURES i128"
fi
case "$TRAVIS_RUST_VERSION" in
1.31.*) STD_FEATURES="serde" ;;
*) STD_FEATURES="serde rand" ;;
esac

case "$TRAVIS_RUST_VERSION" in
1.3[1-5].*) ;;
*) ALLOC_FEATURES="serde rand" ;;
esac

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

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

# test all supported features together
cargo build --features="std $FEATURES"
cargo test --features="std $FEATURES"
cargo build --features="std $STD_FEATURES"
cargo test --features="std $STD_FEATURES"

if test -n "${ALLOC_FEATURES:+true}"; then
# It should build with minimal features too.
cargo build --no-default-features --features="alloc"
cargo test --no-default-features --features="alloc"

# Each isolated feature should also work everywhere.
for feature in $ALLOC_FEATURES; do
cargo build --verbose --no-default-features --features="alloc $feature"
cargo test --verbose --no-default-features --features="alloc $feature"
done

# test all supported features together
cargo build --no-default-features --features="alloc $ALLOC_FEATURES"
cargo test --no-default-features --features="alloc $ALLOC_FEATURES"
fi
25 changes: 8 additions & 17 deletions src/lib.rs
Expand Up @@ -20,8 +20,7 @@
//! approximate a square root to arbitrary precision:
//!
//! ```
//! extern crate num;
//! # #[cfg(feature = "std")]
//! # #[cfg(any(feature = "alloc", feature = "std"))]
//! # mod test {
//!
//! use num::FromPrimitive;
Expand All @@ -41,9 +40,9 @@
//! approx
//! }
//! # }
//! # #[cfg(not(feature = "std"))]
//! # #[cfg(not(any(feature = "alloc", feature = "std")))]
//! # mod test { pub fn approx_sqrt(n: u64, _: usize) -> u64 { n } }
//! # use test::approx_sqrt;
//! # use crate::test::approx_sqrt;
//!
//! fn main() {
//! println!("{}", approx_sqrt(10, 4)); // prints 4057691201/1283082416
Expand All @@ -55,25 +54,17 @@
//!
//! ## Compatibility
//!
//! The `num` crate is tested for rustc 1.15 and greater.
//! The `num` crate is tested for rustc 1.31 and greater.

#![doc(html_root_url = "https://docs.rs/num/0.2")]
#![doc(html_root_url = "https://docs.rs/num/0.3")]
#![no_std]

#[cfg(feature = "std")]
extern crate num_bigint;
extern crate num_complex;
extern crate num_integer;
extern crate num_iter;
extern crate num_rational;
extern crate num_traits;

#[cfg(feature = "std")]
#[cfg(any(feature = "alloc", feature = "std"))]
pub use num_bigint::{BigInt, BigUint};

pub use num_complex::Complex;

#[cfg(feature = "std")]
#[cfg(any(feature = "alloc", feature = "std"))]
pub use num_rational::BigRational;
pub use num_rational::Rational;

Expand All @@ -89,7 +80,7 @@ pub use num_traits::{
Signed, ToPrimitive, Unsigned, Zero,
};

#[cfg(feature = "std")]
#[cfg(any(feature = "alloc", feature = "std"))]
pub mod bigint {
pub use num_bigint::*;
}
Expand Down

0 comments on commit 5d6f64d

Please sign in to comment.