std::rand: Minor clean-up of comments & add a missing default method.

This commit is contained in:
Huon Wilson 2013-10-09 17:39:37 +11:00
parent 5442a47362
commit e678435cab
2 changed files with 5 additions and 3 deletions

View file

@ -648,8 +648,6 @@ impl SeedableRng<[u32, .. 4]> for XorShiftRng {
impl XorShiftRng {
/// Create an xor shift random number generator with a random seed.
pub fn new() -> XorShiftRng {
// generate seeds the same way as seed(), except we have a
// specific size, so we can just use a fixed buffer.
let mut s = [0u8, ..16];
loop {
let mut r = OSRng::new();
@ -714,6 +712,11 @@ impl<R: Rng> Rng for @mut R {
fn next_u64(&mut self) -> u64 {
(**self).next_u64()
}
#[inline]
fn fill_bytes(&mut self, bytes: &mut [u8]) {
(**self).fill_bytes(bytes);
}
}
/// Generate a random value using the task-local random number

View file

@ -863,7 +863,6 @@ fn new_sched_rng() -> XorShiftRng {
use iter::Iterator;
use rand::SeedableRng;
// XXX: this could use io::native::file, when it works.
let fd = do "/dev/urandom".with_c_str |name| {
unsafe { libc::open(name, libc::O_RDONLY, 0) }
};