Skip to content
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

Remove byteorder dependency #360

Merged
merged 1 commit into from
Aug 31, 2023
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: 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 @@ -98,10 +98,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