std::rand: Minor clean-up of comments & add a missing default method.
This commit is contained in:
parent
5442a47362
commit
e678435cab
2 changed files with 5 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) }
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue