Skip to content

Commit

Permalink
Update to rand 0.8 and release 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Mar 6, 2021
1 parent ce0637b commit 12410f8
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 7 deletions.
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
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 12410f8

Please sign in to comment.