core::rand - adding rand::random(), a shortcut to generate a uint with task-local rng
This commit is contained in:
parent
9284179311
commit
0b9a47a189
@ -334,6 +334,13 @@ pub fn task_rng() -> Rng {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random uint, using the task's based random number generator.
|
||||
*/
|
||||
pub fn random() -> uint {
|
||||
task_rng().gen_uint()
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
@ -495,6 +502,12 @@ pub mod tests {
|
||||
assert r.shuffle(~[1, 1, 1]) == ~[1, 1, 1];
|
||||
assert r.gen_uint_range(0u, 1u) == 0u;
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn random() {
|
||||
// not sure how to test this aside from just getting a number
|
||||
let _n : uint = rand::random();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user