/// println!("{}", rng.gen_weighted_bool(3));
/// ```
fn gen_weighted_bool(&mut self, n: uint) -> bool {
- n == 0 || self.gen_range(0, n) == 0
+ n <= 1 || self.gen_range(0, n) == 0
}
/// Return an iterator of random characters from the set A-Z,a-z,0-9.
/// ```
/// use std::rand::{thread_rng, Rng};
///
- /// let choices = [1i, 2, 4, 8, 16, 32];
+ /// let choices = [1, 2, 4, 8, 16, 32];
/// let mut rng = thread_rng();
/// println!("{}", rng.choose(&choices));
/// # // replace with slicing syntax when it's stable!
/// use std::rand::{thread_rng, Rng};
///
/// let mut rng = thread_rng();
- /// let mut y = [1i, 2, 3];
+ /// let mut y = [1, 2, 3];
/// rng.shuffle(&mut y);
/// println!("{}", y.as_slice());
/// rng.shuffle(&mut y);
/// RNGs"](http://www.jstatsoft.org/v08/i14/paper). *Journal of
/// Statistical Software*. Vol. 8 (Issue 14).
#[allow(missing_copy_implementations)]
+#[deriving(Clone)]
pub struct XorShiftRng {
x: u32,
y: u32,
w: u32,
}
-impl Clone for XorShiftRng {
- fn clone(&self) -> XorShiftRng {
- XorShiftRng {
- x: self.x,
- y: self.y,
- z: self.z,
- w: self.w,
- }
- }
-}
-
impl XorShiftRng {
/// Creates a new XorShiftRng instance which is not seeded.
///
#[cfg(not(test))]
mod std {
pub use core::{option, fmt}; // panic!()
+ pub use core::clone; // derive Clone
pub use core::kinds;
}