diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index f6b7dfa568c28..32f77a533a67e 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -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(); + } }