Skip to content

Upgrade to Rand 0.7 #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
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
- stable
- beta
- nightly
Expand All @@ -20,7 +18,7 @@ matrix:
before_script:
- rustup target add $TARGET
script:
- cargo build --verbose --target $TARGET --no-default-features --features i128,rand,serde
- cargo build --verbose --target $TARGET --no-default-features --features rand,serde
- name: "rustfmt"
rust: 1.31.0
before_script:
Expand Down
8 changes: 2 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ name = "num-complex"
repository = "https://github.com/rust-num/num-complex"
version = "0.3.0-pre"
readme = "README.md"
build = "build.rs"
exclude = ["/ci/*", "/.travis.yml", "/bors.toml"]
publish = false

Expand All @@ -22,6 +21,7 @@ features = ["std", "serde", "rand"]
[dependencies.num-traits]
version = "0.2.11"
default-features = false
features = ["i128"]

[dependencies.serde]
optional = true
Expand All @@ -30,13 +30,9 @@ default-features = false

[dependencies.rand]
optional = true
version = "0.5"
version = "0.7"
default-features = false

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

[build-dependencies]
autocfg = "1"
12 changes: 4 additions & 8 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.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-complex.svg?branch=master)](https://travis-ci.org/rust-num/num-complex)

`Complex` numbers for Rust.
Expand All @@ -13,7 +13,7 @@ Add this to your `Cargo.toml`:

```toml
[dependencies]
num-complex = "0.2"
num-complex = "0.3"
```

and this to your crate root:
Expand All @@ -29,22 +29,18 @@ the default `std` feature. Use this in `Cargo.toml`:

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

Features based on `Float` types are only available when `std` is enabled. Where
possible, `FloatCore` is used instead. Formatting complex numbers only supports
format width when `std` is enabled.

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-complex` crate is tested for rustc 1.15 and greater.
The `num-complex` crate is tested for rustc 1.31 and greater.
20 changes: 0 additions & 20 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,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 stable beta nightly; do
run="rustup run $TRAVIS_RUST_VERSION"
$run cargo build --verbose
$run $PWD/ci/test_full.sh
Expand Down
15 changes: 8 additions & 7 deletions ci/test_full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ set -ex

echo Testing num-complex on rustc ${TRAVIS_RUST_VERSION}

FEATURES="std 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.*) FEATURES="serde" ;;
*) FEATURES="serde rand" ;;
esac

# num-complex should build and test everywhere.
cargo build --verbose
Expand All @@ -29,3 +26,7 @@ done
# test all supported features together
cargo build --features="$FEATURES"
cargo test --features="$FEATURES"

# test all supported features together with std
cargo build --features="std $FEATURES"
cargo test --features="std $FEATURES"
4 changes: 0 additions & 4 deletions src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ impl<T: ToPrimitive + Num> ToPrimitive for Complex<T> {
impl_to_primitive!(i16, to_i16);
impl_to_primitive!(i32, to_i32);
impl_to_primitive!(i64, to_i64);
#[cfg(has_i128)]
impl_to_primitive!(u128, to_u128);
#[cfg(has_i128)]
impl_to_primitive!(i128, to_i128);
impl_to_primitive!(f32, to_f32);
impl_to_primitive!(f64, to_f64);
Expand Down Expand Up @@ -53,9 +51,7 @@ impl<T: FromPrimitive + Num> FromPrimitive for Complex<T> {
impl_from_primitive!(i16, from_i16);
impl_from_primitive!(i32, from_i32);
impl_from_primitive!(i64, from_i64);
#[cfg(has_i128)]
impl_from_primitive!(u128, from_u128);
#[cfg(has_i128)]
impl_from_primitive!(i128, from_i128);
impl_from_primitive!(f32, from_f32);
impl_from_primitive!(f64, from_f64);
Expand Down
4 changes: 2 additions & 2 deletions src/crand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ where
}

#[cfg(test)]
fn test_rng() -> SmallRng {
SmallRng::from_seed([42; 16])
fn test_rng() -> StdRng {
StdRng::from_seed([42; 32])
}

#[test]
Expand Down
16 changes: 2 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
//!
//! ## Compatibility
//!
//! The `num-complex` crate is tested for rustc 1.15 and greater.
//! The `num-complex` crate is tested for rustc 1.31 and greater.

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

#[cfg(any(test, feature = "std"))]
Expand Down Expand Up @@ -93,19 +93,11 @@ pub type Complex32 = Complex<f32>;
pub type Complex64 = Complex<f64>;

impl<T> Complex<T> {
#[cfg(has_const_fn)]
/// Create a new Complex
#[inline]
pub const fn new(re: T, im: T) -> Self {
Complex { re: re, im: im }
}

#[cfg(not(has_const_fn))]
/// Create a new Complex
#[inline]
pub fn new(re: T, im: T) -> Self {
Complex { re: re, im: im }
}
}

impl<T: Clone + Num> Complex<T> {
Expand Down Expand Up @@ -1086,9 +1078,6 @@ impl<T: Clone + Num> Rem<T> for Complex<T> {
}
}

#[cfg(not(has_i128))]
real_arithmetic!(usize, u8, u16, u32, u64, isize, i8, i16, i32, i64, f32, f64);
#[cfg(has_i128)]
real_arithmetic!(usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64);

/* constants */
Expand Down Expand Up @@ -2650,7 +2639,6 @@ mod test {
assert!(c.is_one());
}

#[cfg(has_const_fn)]
#[test]
fn test_const() {
const R: f64 = 12.3;
Expand Down
1 change: 0 additions & 1 deletion src/pow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ pow_impl!(u16, i16);
pow_impl!(u32, i32);
pow_impl!(u64, i64);
pow_impl!(usize, isize);
#[cfg(has_i128)]
pow_impl!(u128, i128);

// Note: we can't add `impl<T: Float> Pow<T> for Complex<T>` because new blanket impls are a
Expand Down