From b8b2d1e5b41fd3351049fbb54846b42aa9b189bd Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Tue, 18 Jun 2013 11:54:00 -0700 Subject: [PATCH] Make task_rng() return @mut R instead of @@mut R --- src/libstd/rand.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs index 739e3dfedc7..27ec5323841 100644 --- a/src/libstd/rand.rs +++ b/src/libstd/rand.rs @@ -843,7 +843,7 @@ fn tls_rng_state(_v: @@mut IsaacRng) {} * `task_rng().gen::()`. */ #[inline] -pub fn task_rng() -> @@mut IsaacRng { +pub fn task_rng() -> @mut IsaacRng { let r : Option<@@mut IsaacRng>; unsafe { r = local_data::local_data_get(tls_rng_state); @@ -853,20 +853,18 @@ pub fn task_rng() -> @@mut IsaacRng { unsafe { let rng = @@mut IsaacRng::new_seeded(seed()); local_data::local_data_set(tls_rng_state, rng); - rng + *rng } } - Some(rng) => rng + Some(rng) => *rng } } // Allow direct chaining with `task_rng` -impl Rng for @@mut R { +impl Rng for @mut R { #[inline] fn next(&mut self) -> u32 { - match *self { - @@ref mut r => r.next() - } + (**self).next() } } @@ -876,9 +874,7 @@ impl Rng for @@mut R { */ #[inline] pub fn random() -> T { - match *task_rng() { - @ref mut r => r.gen() - } + task_rng().gen() } #[cfg(test)]