Skip to content

Commit

Permalink
Merge pull request #121 from cuviper/msrv-1.60
Browse files Browse the repository at this point in the history
Use namespaced-features to safely bump to MSRV 1.60
  • Loading branch information
cuviper authored Mar 25, 2024
2 parents 0eb3e90 + 0c3f2ef commit f66164b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 32 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ jobs:
strategy:
matrix:
rust: [
1.31.0, # 2018!
1.36.0, # rand
1.54.0, # rkyv
1.60.0, # MSRV
stable,
beta,
nightly
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.31.0, stable]
rust: [1.60.0, stable]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
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.31.0, stable]
rust: [1.60.0, stable]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand Down
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ repository = "https://github.com/rust-num/num-complex"
version = "0.4.5"
readme = "README.md"
exclude = ["/ci/*", "/.github/*"]
edition = "2018"
edition = "2021"
rust-version = "1.60"

[package.metadata.docs.rs]
features = ["bytemuck", "std", "serde", "rkyv/size_64", "bytecheck", "rand"]
Expand Down Expand Up @@ -51,3 +52,8 @@ default-features = false
default = ["std"]
std = ["num-traits/std"]
libm = ["num-traits/libm"]
bytecheck = ["dep:bytecheck"]
bytemuck = ["dep:bytemuck"]
rand = ["dep:rand"]
rkyv = ["dep:rkyv"]
serde = ["dep:serde"]
4 changes: 2 additions & 2 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-complex.svg)](https://crates.io/crates/num-complex)
[![documentation](https://docs.rs/num-complex/badge.svg)](https://docs.rs/num-complex)
[![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)
[![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)
[![build status](https://github.com/rust-num/num-complex/workflows/master/badge.svg)](https://github.com/rust-num/num-complex/actions)

`Complex` numbers for Rust.
Expand Down Expand Up @@ -37,7 +37,7 @@ Release notes are available in [RELEASES.md](RELEASES.md).

## Compatibility

The `num-complex` crate is tested for rustc 1.31 and greater.
The `num-complex` crate is tested for rustc 1.60 and greater.

## License

Expand Down
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.31.0 1.36.0 1.54.0 stable beta nightly; do
for version in 1.60.0 stable beta nightly; do
rustup run "$version" "$ci/test_full.sh"
done
19 changes: 2 additions & 17 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-complex
MSRV=1.31
MSRV=1.60

get_rust_version() {
local array=($(rustc --version));
Expand All @@ -27,26 +27,11 @@ if ! check_version $MSRV ; then
exit 1
fi

FEATURES=(libm serde)
check_version 1.34 && FEATURES+=(bytemuck)
check_version 1.36 && FEATURES+=(rand)
check_version 1.54 && FEATURES+=(rkyv/size_64 bytecheck)
FEATURES=(bytecheck bytemuck libm rand rkyv/size_64 serde)
echo "Testing supported features: ${FEATURES[*]}"

cargo generate-lockfile

# libm 0.2.6 started using {float}::EPSILON
check_version 1.43 || cargo update -p libm --precise 0.2.5

# Some crates moved to Rust 1.56 / 2021
check_version 1.56 || (
cargo update -p serde --precise 1.0.185
cargo update -p quote --precise 1.0.30
cargo update -p proc-macro2 --precise 1.0.65
cargo update -p rkyv --precise 0.7.40
cargo update -p bytecheck --precise 0.6.9
)

set -x

# test the default
Expand Down
10 changes: 4 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,11 @@ impl<T: Float> Complex<T> {
if !im.is_finite() {
return Self::new(T::zero(), T::zero());
}
} else {
if im == T::zero() || !im.is_finite() {
if im.is_infinite() {
im = T::nan();
}
return Self::new(re, im);
} else if im == T::zero() || !im.is_finite() {
if im.is_infinite() {
im = T::nan();
}
return Self::new(re, im);
}
} else if re.is_nan() && im == T::zero() {
return self;
Expand Down

0 comments on commit f66164b

Please sign in to comment.