Skip to content

Commit e580ced

Browse files
authored
Merge pull request #126 from cuviper/msrv-1.60
Use namespaced-features to safely bump to MSRV 1.60
2 parents 3303b7d + 50e44c7 commit e580ced

File tree

9 files changed

+36
-64
lines changed

9 files changed

+36
-64
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
rust: [
12-
1.31.0, # 2018!
13-
1.36.0, # alloc
12+
1.60.0, # MSRV
1413
stable,
1514
beta,
1615
nightly
@@ -29,7 +28,7 @@ jobs:
2928
- run: ./ci/test_full.sh
3029

3130
# try a target that doesn't have std at all, but does have alloc
32-
no_std_stable:
31+
no_std:
3332
name: No Std (stable)
3433
runs-on: ubuntu-latest
3534
steps:
@@ -39,21 +38,6 @@ jobs:
3938
target: thumbv6m-none-eabi
4039
- run: cargo build --target thumbv6m-none-eabi --no-default-features --features "num-bigint serde"
4140

42-
# try a target that doesn't have std at all, nor alloc
43-
no_std_131:
44-
name: No Std (1.31.0)
45-
runs-on: ubuntu-latest
46-
steps:
47-
- uses: actions/checkout@v4
48-
- uses: actions/cache@v4
49-
with:
50-
path: ~/.cargo/registry/index
51-
key: cargo-1.31.0-git-index
52-
- uses: dtolnay/rust-toolchain@1.31.0
53-
with:
54-
target: thumbv6m-none-eabi
55-
- run: cargo build --target thumbv6m-none-eabi --no-default-features --features "serde"
56-
5741
fmt:
5842
name: Format
5943
runs-on: ubuntu-latest
@@ -69,7 +53,7 @@ jobs:
6953
success:
7054
name: Success
7155
runs-on: ubuntu-latest
72-
needs: [test, no_std_131, no_std_stable, fmt]
56+
needs: [test, no_std, fmt]
7357
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
7458
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
7559
# dependencies fails.

.github/workflows/master.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
rust: [1.31.0, stable]
16+
rust: [1.60.0, stable]
1717
steps:
1818
- uses: actions/checkout@v4
1919
- uses: actions/cache@v4

.github/workflows/pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
rust: [1.31.0, stable]
12+
rust: [1.60.0, stable]
1313
steps:
1414
- uses: actions/checkout@v4
1515
- uses: actions/cache@v4

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ repository = "https://github.com/rust-num/num-rational"
1111
version = "0.4.1"
1212
readme = "README.md"
1313
exclude = ["/ci/*", "/.github/*"]
14-
edition = "2018"
14+
edition = "2021"
15+
rust-version = "1.60"
1516

1617
[package.metadata.docs.rs]
1718
features = ["std", "num-bigint-std", "serde"]
@@ -39,9 +40,8 @@ version = "1.0.0"
3940
default-features = false
4041

4142
[features]
42-
default = ["num-bigint-std", "std"]
43-
std = ["num-integer/std", "num-traits/std"]
43+
default = ["num-bigint", "std"]
44+
std = ["num-bigint?/std", "num-integer/std", "num-traits/std"]
4445
num-bigint-std = ["num-bigint/std"]
45-
46-
[build-dependencies]
47-
autocfg = "1.0.0"
46+
num-bigint = ["dep:num-bigint"]
47+
serde = ["dep:serde"]

README.md

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

33
[![crate](https://img.shields.io/crates/v/num-rational.svg)](https://crates.io/crates/num-rational)
44
[![documentation](https://docs.rs/num-rational/badge.svg)](https://docs.rs/num-rational)
5-
[![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)
5+
[![minimum rustc 1.60](https://img.shields.io/badge/rustc-1.60+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
66
[![build status](https://github.com/rust-num/num-rational/workflows/master/badge.svg)](https://github.com/rust-num/num-rational/actions)
77

88
Generic `Rational` numbers (aka fractions) for Rust.
@@ -33,7 +33,7 @@ Release notes are available in [RELEASES.md](RELEASES.md).
3333

3434
## Compatibility
3535

36-
The `num-rational` crate is tested for rustc 1.31 and greater.
36+
The `num-rational` crate is tested for rustc 1.60 and greater.
3737

3838
## License
3939

build.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

ci/rustup.sh

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

77
ci=$(dirname $0)
8-
for version in 1.31.0 1.36.0 stable beta nightly; do
8+
for version in 1.60.0 stable beta nightly; do
99
rustup run "$version" "$ci/test_full.sh"
1010
done

ci/test_full.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
CRATE=num-rational
6-
MSRV=1.31
6+
MSRV=1.60
77

88
get_rust_version() {
99
local array=($(rustc --version));
@@ -28,8 +28,7 @@ if ! check_version $MSRV ; then
2828
fi
2929

3030
STD_FEATURES=(num-bigint-std serde)
31-
NO_STD_FEATURES=(serde)
32-
check_version 1.36 && NO_STD_FEATURES+=(num-bigint)
31+
NO_STD_FEATURES=(num-bigint serde)
3332
echo "Testing supported features: ${STD_FEATURES[*]}"
3433
echo " no_std supported features: ${NO_STD_FEATURES[*]}"
3534

src/lib.rs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//!
1313
//! ## Compatibility
1414
//!
15-
//! The `num-rational` crate is tested for rustc 1.31 and greater.
15+
//! The `num-rational` crate is tested for rustc 1.60 and greater.
1616
1717
#![doc(html_root_url = "https://docs.rs/num-rational/0.4")]
1818
#![no_std]
@@ -73,7 +73,7 @@ pub type Rational64 = Ratio<i64>;
7373
/// Alias for arbitrary precision rationals.
7474
pub type BigRational = Ratio<BigInt>;
7575

76-
/// These method are `const` for Rust 1.31 and later.
76+
/// These method are `const`.
7777
impl<T> Ratio<T> {
7878
/// Creates a `Ratio` without checking for `denom == 0` or reducing.
7979
///
@@ -1124,9 +1124,9 @@ impl<T: FromStr + Clone + Integer> FromStr for Ratio<T> {
11241124
}
11251125
}
11261126

1127-
impl<T> Into<(T, T)> for Ratio<T> {
1128-
fn into(self) -> (T, T) {
1129-
(self.numer, self.denom)
1127+
impl<T> From<Ratio<T>> for (T, T) {
1128+
fn from(val: Ratio<T>) -> Self {
1129+
(val.numer, val.denom)
11301130
}
11311131
}
11321132

@@ -2111,24 +2111,21 @@ mod test {
21112111
assert_fmt_eq!(format_args!("{:X}", -half_i8), "FF/2");
21122112
assert_fmt_eq!(format_args!("{:#X}", -half_i8), "0xFF/0x2");
21132113

2114-
#[cfg(has_int_exp_fmt)]
2115-
{
2116-
assert_fmt_eq!(format_args!("{:e}", -_2), "-2e0");
2117-
assert_fmt_eq!(format_args!("{:#e}", -_2), "-2e0");
2118-
assert_fmt_eq!(format_args!("{:+e}", -_2), "-2e0");
2119-
assert_fmt_eq!(format_args!("{:e}", _BILLION), "1e9");
2120-
assert_fmt_eq!(format_args!("{:+e}", _BILLION), "+1e9");
2121-
assert_fmt_eq!(format_args!("{:e}", _BILLION.recip()), "1e0/1e9");
2122-
assert_fmt_eq!(format_args!("{:+e}", _BILLION.recip()), "+1e0/1e9");
2123-
2124-
assert_fmt_eq!(format_args!("{:E}", -_2), "-2E0");
2125-
assert_fmt_eq!(format_args!("{:#E}", -_2), "-2E0");
2126-
assert_fmt_eq!(format_args!("{:+E}", -_2), "-2E0");
2127-
assert_fmt_eq!(format_args!("{:E}", _BILLION), "1E9");
2128-
assert_fmt_eq!(format_args!("{:+E}", _BILLION), "+1E9");
2129-
assert_fmt_eq!(format_args!("{:E}", _BILLION.recip()), "1E0/1E9");
2130-
assert_fmt_eq!(format_args!("{:+E}", _BILLION.recip()), "+1E0/1E9");
2131-
}
2114+
assert_fmt_eq!(format_args!("{:e}", -_2), "-2e0");
2115+
assert_fmt_eq!(format_args!("{:#e}", -_2), "-2e0");
2116+
assert_fmt_eq!(format_args!("{:+e}", -_2), "-2e0");
2117+
assert_fmt_eq!(format_args!("{:e}", _BILLION), "1e9");
2118+
assert_fmt_eq!(format_args!("{:+e}", _BILLION), "+1e9");
2119+
assert_fmt_eq!(format_args!("{:e}", _BILLION.recip()), "1e0/1e9");
2120+
assert_fmt_eq!(format_args!("{:+e}", _BILLION.recip()), "+1e0/1e9");
2121+
2122+
assert_fmt_eq!(format_args!("{:E}", -_2), "-2E0");
2123+
assert_fmt_eq!(format_args!("{:#E}", -_2), "-2E0");
2124+
assert_fmt_eq!(format_args!("{:+E}", -_2), "-2E0");
2125+
assert_fmt_eq!(format_args!("{:E}", _BILLION), "1E9");
2126+
assert_fmt_eq!(format_args!("{:+E}", _BILLION), "+1E9");
2127+
assert_fmt_eq!(format_args!("{:E}", _BILLION.recip()), "1E0/1E9");
2128+
assert_fmt_eq!(format_args!("{:+E}", _BILLION.recip()), "+1E0/1E9");
21322129
}
21332130

21342131
mod arith {

0 commit comments

Comments
 (0)