Skip to content

Commit

Permalink
Merge #89
Browse files Browse the repository at this point in the history
89: Update to rand 0.8 and release 0.4.0 r=cuviper a=cuviper



Co-authored-by: Josh Stone <cuviper@gmail.com>
  • Loading branch information
bors[bot] and cuviper committed Mar 6, 2021
2 parents ce0637b + fc629e6 commit 3a89daa
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
rust: [
1.31.0, # 2018!
1.32.0, # rand
1.36.0, # rand
stable,
beta,
nightly
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Expand Up @@ -8,7 +8,7 @@ categories = ["algorithms", "data-structures", "science", "no-std"]
license = "MIT OR Apache-2.0"
name = "num-complex"
repository = "https://github.com/rust-num/num-complex"
version = "0.3.1"
version = "0.4.0"
readme = "README.md"
exclude = ["/bors.toml", "/ci/*", "/.github/*"]
edition = "2018"
Expand All @@ -30,7 +30,7 @@ default-features = false

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

[features]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -13,7 +13,7 @@ Add this to your `Cargo.toml`:

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

## Features
Expand All @@ -23,7 +23,7 @@ the default `std` feature. Use this in `Cargo.toml`:

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

Expand Down
6 changes: 6 additions & 0 deletions RELEASES.md
@@ -1,3 +1,9 @@
# Release 0.4.0 (2021-03-05)

- `rand` support has been updated to 0.8, requiring Rust 1.36.

**Contributors**: @cuviper

# Release 0.3.1 (2020-10-29)

- Clarify the license specification as "MIT OR Apache-2.0".
Expand Down
2 changes: 1 addition & 1 deletion bors.toml
@@ -1,6 +1,6 @@
status = [
"Test (1.31.0)",
"Test (1.32.0)",
"Test (1.36.0)",
"Test (stable)",
"Test (beta)",
"Test (nightly)",
Expand Down
2 changes: 1 addition & 1 deletion ci/rustup.sh
Expand Up @@ -5,6 +5,6 @@
set -ex

ci=$(dirname $0)
for version in 1.31.0 1.32.0 stable beta nightly; do
for version in 1.31.0 1.36.0 stable beta nightly; do
rustup run "$version" "$ci/test_full.sh"
done
2 changes: 1 addition & 1 deletion ci/test_full.sh
Expand Up @@ -28,7 +28,7 @@ if ! check_version $MSRV ; then
fi

FEATURES=(libm serde)
check_version 1.32 && FEATURES+=(rand)
check_version 1.36 && FEATURES+=(rand)
echo "Testing supported features: ${FEATURES[*]}"

set -x
Expand Down
37 changes: 35 additions & 2 deletions src/crand.rs
Expand Up @@ -42,8 +42,41 @@ where
}

#[cfg(test)]
fn test_rng() -> StdRng {
StdRng::from_seed([42; 32])
fn test_rng() -> impl RngCore {
/// Simple `Rng` for testing without additional dependencies
struct XorShiftStar {
a: u64,
}

impl RngCore for XorShiftStar {
fn next_u32(&mut self) -> u32 {
self.next_u64() as u32
}

fn next_u64(&mut self) -> u64 {
// https://en.wikipedia.org/wiki/Xorshift#xorshift*
self.a ^= self.a >> 12;
self.a ^= self.a << 25;
self.a ^= self.a >> 27;
self.a.wrapping_mul(0x2545_F491_4F6C_DD1D)
}

fn fill_bytes(&mut self, dest: &mut [u8]) {
for chunk in dest.chunks_mut(8) {
let bytes = self.next_u64().to_le_bytes();
let slice = &bytes[..chunk.len()];
chunk.copy_from_slice(slice)
}
}

fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> {
Ok(self.fill_bytes(dest))
}
}

XorShiftStar {
a: 0x0123_4567_89AB_CDEF,
}
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -14,7 +14,7 @@
//!
//! The `num-complex` crate is tested for rustc 1.31 and greater.

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

#[cfg(any(test, feature = "std"))]
Expand Down

0 comments on commit 3a89daa

Please sign in to comment.