Skip to content

Commit

Permalink
Merge pull request #360 from psychon/remove-byteorder
Browse files Browse the repository at this point in the history
Remove byteorder dependency
  • Loading branch information
rex-remind101 authored Aug 31, 2023
2 parents 466d59d + 31d8530 commit 7292965
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
6 changes: 1 addition & 5 deletions proptest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ default-code-coverage = ["std", "fork", "timeout", "bit-set"]
unstable = []

# Enables the use of standard-library dependent features
std = ["rand/std", "byteorder/std", "lazy_static",
std = ["rand/std", "lazy_static",
"regex-syntax", "num-traits/std"]

# For use in no_std environments with access to an allocator
Expand Down Expand Up @@ -102,10 +102,6 @@ version = "0.3"
version = "0.3"
default-features = false

[dependencies.byteorder]
version = "1.2.3"
default-features = false

[dependencies.rusty-fork]
version = "0.3.0"
optional = true
Expand Down
19 changes: 12 additions & 7 deletions proptest/src/test_runner/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@

use crate::std_facade::{Arc, String, ToOwned, Vec};
use core::result::Result;
use core::{fmt, str, u8};
use core::{fmt, str, u8, convert::TryInto};

use byteorder::{ByteOrder, LittleEndian};
use rand::{self, Rng, RngCore, SeedableRng};
use rand_chacha::ChaChaRng;
use rand_xorshift::XorShiftRng;
Expand Down Expand Up @@ -137,7 +136,7 @@ impl RngCore for TestRng {
&mut TestRngImpl::PassThrough { .. } => {
let mut buf = [0; 4];
self.fill_bytes(&mut buf[..]);
LittleEndian::read_u32(&buf[..])
u32::from_le_bytes(buf)
}

&mut TestRngImpl::Recorder {
Expand All @@ -160,7 +159,7 @@ impl RngCore for TestRng {
&mut TestRngImpl::PassThrough { .. } => {
let mut buf = [0; 8];
self.fill_bytes(&mut buf[..]);
LittleEndian::read_u64(&buf[..])
u64::from_le_bytes(buf)
}

&mut TestRngImpl::Recorder {
Expand Down Expand Up @@ -302,7 +301,9 @@ impl Seed {
}

let mut seed = [0u8; 16];
LittleEndian::write_u32_into(&dwords[..], &mut seed[..]);
for (chunk, dword) in seed.chunks_mut(4).zip(dwords) {
chunk.copy_from_slice(&dword.to_le_bytes());
}
Some(Seed::XorShift(seed))
}

Expand Down Expand Up @@ -354,8 +355,12 @@ impl Seed {

match *self {
Seed::XorShift(ref seed) => {
let mut dwords = [0u32; 4];
LittleEndian::read_u32_into(seed, &mut dwords[..]);
let dwords = [
u32::from_le_bytes(seed[0..4].try_into().unwrap()),
u32::from_le_bytes(seed[4..8].try_into().unwrap()),
u32::from_le_bytes(seed[8..12].try_into().unwrap()),
u32::from_le_bytes(seed[12..16].try_into().unwrap()),
];
format!(
"{} {} {} {} {}",
RngAlgorithm::XorShift.persistence_key(),
Expand Down

0 comments on commit 7292965

Please sign in to comment.