Skip to content

Remove weak_rng #3

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

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 3 additions & 20 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,22 +740,6 @@ impl<'a> SeedableRng<&'a [usize]> for StdRng {
}
}

/// Create a weak random number generator with a default algorithm and seed.
///
/// It returns the fastest `Rng` algorithm currently available in Rust without
/// consideration for cryptography or security. If you require a specifically
/// seeded `Rng` for consistency over time you should pick one algorithm and
/// create the `Rng` yourself.
///
/// This will read randomness from the operating system to seed the
/// generator.
pub fn weak_rng() -> XorShiftRng {
match OsRng::new() {
Ok(mut r) => r.gen(),
Err(e) => panic!("weak_rng: failed to create seeded RNG: {:?}", e)
}
}

/// Controls how the thread-local RNG is reseeded.
struct ThreadRngReseeder;

Expand Down Expand Up @@ -910,7 +894,7 @@ mod test {
}

pub fn weak_rng() -> MyRng<::XorShiftRng> {
MyRng { inner: ::weak_rng() }
MyRng { inner: random() }
}

struct ConstRng { i: u64 }
Expand Down Expand Up @@ -1106,8 +1090,7 @@ static RAND_BENCH_N: u64 = 100;
mod bench {
extern crate test;
use self::test::Bencher;
use super::{XorShiftRng, StdRng, IsaacRng, Isaac64Rng, Rng, RAND_BENCH_N};
use super::{OsRng, weak_rng};
use super::{random, XorShiftRng, StdRng, IsaacRng, Isaac64Rng, OsRng, Rng, RAND_BENCH_N};
use std::mem::size_of;

#[bench]
Expand Down Expand Up @@ -1156,7 +1139,7 @@ mod bench {

#[bench]
fn rand_shuffle_100(b: &mut Bencher) {
let mut rng = weak_rng();
let mut rng: XorShiftRng = random();
let x : &mut[uint] = &mut [1; 100];
b.iter(|| {
rng.shuffle(x);
Expand Down