Skip to content

Commit

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



Co-authored-by: Josh Stone <cuviper@gmail.com>
  • Loading branch information
bors[bot] and cuviper authored Jul 14, 2022
2 parents 543e0c9 + b883758 commit f9ef6c0
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 133 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.8.0, 1.15.0, 1.20.0, 1.26.0, 1.31.0, stable, beta, nightly]
rust: [
1.31.0, # MSRV
stable,
beta,
nightly,
]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
Expand All @@ -30,7 +35,7 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
with:
target: thumbv6m-none-eabi
- run: cargo build --target thumbv6m-none-eabi --no-default-features --features i128
- run: cargo build --target thumbv6m-none-eabi --no-default-features

fmt:
name: Format
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.8.0, stable]
rust: [1.31.0, stable]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.8.0, stable]
rust: [1.31.0, stable]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
Expand Down
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@ repository = "https://github.com/rust-num/num-integer"
name = "num-integer"
version = "0.1.45"
readme = "README.md"
build = "build.rs"
exclude = ["/bors.toml", "/ci/*", "/.github/*"]
edition = "2018"
rust-version = "1.31"

[package.metadata.docs.rs]
features = ["std"]

[dependencies.num-traits]
version = "0.2.11"
default-features = false
features = ["i128"]

[features]
default = ["std"]
i128 = ["num-traits/i128"]
std = ["num-traits/std"]

[build-dependencies]
autocfg = "1"
# vestigial features, now always in effect
i128 = []
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![crate](https://img.shields.io/crates/v/num-integer.svg)](https://crates.io/crates/num-integer)
[![documentation](https://docs.rs/num-integer/badge.svg)](https://docs.rs/num-integer)
[![minimum rustc 1.8](https://img.shields.io/badge/rustc-1.8+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
[![minimum rustc 1.31](https://img.shields.io/badge/rustc-1.31+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
[![build status](https://github.com/rust-num/num-integer/workflows/master/badge.svg)](https://github.com/rust-num/num-integer/actions)

`Integer` trait and functions for Rust.
Expand All @@ -16,12 +16,6 @@ Add this to your `Cargo.toml`:
num-integer = "0.1"
```

and this to your crate root:

```rust
extern crate num_integer;
```

## Features

This crate can be used without the standard library (`#![no_std]`) by disabling
Expand All @@ -36,17 +30,13 @@ default-features = false
There is no functional difference with and without `std` at this time, but
there may be in the future.

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.

## Releases

Release notes are available in [RELEASES.md](RELEASES.md).

## Compatibility

The `num-integer` crate is tested for rustc 1.8 and greater.
The `num-integer` crate is tested for rustc 1.31 and greater.

## License

Expand Down
18 changes: 6 additions & 12 deletions benches/average.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#![feature(test)]

extern crate num_integer;
extern crate num_traits;
extern crate test;

use num_integer::Integer;
Expand Down Expand Up @@ -143,12 +141,10 @@ where
assert_eq!(rt - a, b - rt + T::one());
}
// if both number have a different sign,
} else if (a + b).is_even() {
assert_eq!(rt, (a + b) / (T::one() + T::one()))
} else {
if (a + b).is_even() {
assert_eq!(rt, (a + b) / (T::one() + T::one()))
} else {
assert_eq!(rt, (a + b + T::one()) / (T::one() + T::one()))
}
assert_eq!(rt, (a + b + T::one()) / (T::one() + T::one()))
}
}
bench_unchecked(b, v, f);
Expand All @@ -170,12 +166,10 @@ where
assert_eq!(rt - a + T::one(), b - rt);
}
// if both number have a different sign,
} else if (a + b).is_even() {
assert_eq!(rt, (a + b) / (T::one() + T::one()))
} else {
if (a + b).is_even() {
assert_eq!(rt, (a + b) / (T::one() + T::one()))
} else {
assert_eq!(rt, (a + b - T::one()) / (T::one() + T::one()))
}
assert_eq!(rt, (a + b - T::one()) / (T::one() + T::one()))
}
}
bench_unchecked(b, v, f);
Expand Down
2 changes: 0 additions & 2 deletions benches/gcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#![feature(test)]

extern crate num_integer;
extern crate num_traits;
extern crate test;

use num_integer::Integer;
Expand Down
18 changes: 8 additions & 10 deletions benches/roots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#![feature(test)]

extern crate num_integer;
extern crate num_traits;
extern crate test;

use num_integer::Integer;
Expand Down Expand Up @@ -125,42 +123,42 @@ macro_rules! bench_roots {

#[bench]
fn sqrt_rand(b: &mut Bencher) {
::bench_rand_pos(b, $T::sqrt, 2);
crate::bench_rand_pos(b, $T::sqrt, 2);
}

#[bench]
fn sqrt_small(b: &mut Bencher) {
::bench_small_pos(b, $T::sqrt, 2);
crate::bench_small_pos(b, $T::sqrt, 2);
}

#[bench]
fn cbrt_rand(b: &mut Bencher) {
::bench_rand(b, $T::cbrt, 3);
crate::bench_rand(b, $T::cbrt, 3);
}

#[bench]
fn cbrt_small(b: &mut Bencher) {
::bench_small(b, $T::cbrt, 3);
crate::bench_small(b, $T::cbrt, 3);
}

#[bench]
fn fourth_root_rand(b: &mut Bencher) {
::bench_rand_pos(b, |x: &$T| x.nth_root(4), 4);
crate::bench_rand_pos(b, |x: &$T| x.nth_root(4), 4);
}

#[bench]
fn fourth_root_small(b: &mut Bencher) {
::bench_small_pos(b, |x: &$T| x.nth_root(4), 4);
crate::bench_small_pos(b, |x: &$T| x.nth_root(4), 4);
}

#[bench]
fn fifth_root_rand(b: &mut Bencher) {
::bench_rand(b, |x: &$T| x.nth_root(5), 5);
crate::bench_rand(b, |x: &$T| x.nth_root(5), 5);
}

#[bench]
fn fifth_root_small(b: &mut Bencher) {
::bench_small(b, |x: &$T| x.nth_root(5), 5);
crate::bench_small(b, |x: &$T| x.nth_root(5), 5);
}
}
)*}
Expand Down
4 changes: 0 additions & 4 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
status = [
"Test (1.8.0)",
"Test (1.15.0)",
"Test (1.20.0)",
"Test (1.26.0)",
"Test (1.31.0)",
"Test (stable)",
"Test (beta)",
Expand Down
13 changes: 0 additions & 13 deletions build.rs

This file was deleted.

2 changes: 1 addition & 1 deletion ci/rustup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
set -ex

ci=$(dirname $0)
for version in 1.8.0 1.15.0 1.20.0 1.26.0 1.31.0 stable beta nightly; do
for version in 1.31.0 stable beta nightly; do
rustup run "$version" "$ci/test_full.sh"
done
3 changes: 1 addition & 2 deletions ci/test_full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

CRATE=num-integer
MSRV=1.8
MSRV=1.31

get_rust_version() {
local array=($(rustc --version));
Expand All @@ -28,7 +28,6 @@ if ! check_version $MSRV ; then
fi

FEATURES=()
check_version 1.26 && FEATURES+=(i128)
echo "Testing supported features: ${FEATURES[*]}"

set -x
Expand Down
2 changes: 1 addition & 1 deletion src/average.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Integer;
use core::ops::{BitAnd, BitOr, BitXor, Shr};
use Integer;

/// Provides methods to compute the average of two integers, without overflows.
pub trait Average: Integer {
Expand Down
Loading

0 comments on commit f9ef6c0

Please sign in to comment.