From ca397681bbacbc115ed540e90ac6f85242e42009 Mon Sep 17 00:00:00 2001 From: Srinivas Reddy Thatiparthy Date: Wed, 12 Oct 2016 23:40:25 +0530 Subject: [PATCH] run rustfmt on librand --- src/librand/chacha.rs | 8 ++++---- src/librand/distributions/mod.rs | 12 ++---------- src/librand/isaac.rs | 16 ++++++++-------- src/librand/rand_impls.rs | 6 +----- src/librand/reseeding.rs | 6 +++--- 5 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/librand/chacha.rs b/src/librand/chacha.rs index 5fba44a1c38f1..8ca1738bb18f4 100644 --- a/src/librand/chacha.rs +++ b/src/librand/chacha.rs @@ -217,8 +217,8 @@ mod tests { let mut ra: ChaChaRng = SeedableRng::from_seed(&*s); let mut rb: ChaChaRng = SeedableRng::from_seed(&*s); assert!(ra.gen_ascii_chars() - .take(100) - .eq(rb.gen_ascii_chars().take(100))); + .take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] @@ -227,8 +227,8 @@ mod tests { let mut ra: ChaChaRng = SeedableRng::from_seed(seed); let mut rb: ChaChaRng = SeedableRng::from_seed(seed); assert!(ra.gen_ascii_chars() - .take(100) - .eq(rb.gen_ascii_chars().take(100))); + .take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs index 36c9f783ff5e0..c5588d94876c0 100644 --- a/src/librand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -237,18 +237,10 @@ fn ziggurat(rng: &mut R, // u is either U(-1, 1) or U(0, 1) depending on if this is a // symmetric distribution or not. - let u = if symmetric { - 2.0 * f - 1.0 - } else { - f - }; + let u = if symmetric { 2.0 * f - 1.0 } else { f }; let x = u * x_tab[i]; - let test_x = if symmetric { - x.abs() - } else { - x - }; + let test_x = if symmetric { x.abs() } else { x }; // algebraically equivalent to |u| < x_tab[i+1]/x_tab[i] (or u < x_tab[i+1]/x_tab[i]) if test_x < x_tab[i + 1] { diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index e8cc7b5cc2dac..974f65ac2c5b5 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -599,8 +599,8 @@ mod tests { let mut ra: IsaacRng = SeedableRng::from_seed(&s[..]); let mut rb: IsaacRng = SeedableRng::from_seed(&s[..]); assert!(ra.gen_ascii_chars() - .take(100) - .eq(rb.gen_ascii_chars().take(100))); + .take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] fn test_rng_64_rand_seeded() { @@ -608,8 +608,8 @@ mod tests { let mut ra: Isaac64Rng = SeedableRng::from_seed(&s[..]); let mut rb: Isaac64Rng = SeedableRng::from_seed(&s[..]); assert!(ra.gen_ascii_chars() - .take(100) - .eq(rb.gen_ascii_chars().take(100))); + .take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] @@ -618,8 +618,8 @@ mod tests { let mut ra: IsaacRng = SeedableRng::from_seed(seed); let mut rb: IsaacRng = SeedableRng::from_seed(seed); assert!(ra.gen_ascii_chars() - .take(100) - .eq(rb.gen_ascii_chars().take(100))); + .take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] fn test_rng_64_seeded() { @@ -627,8 +627,8 @@ mod tests { let mut ra: Isaac64Rng = SeedableRng::from_seed(seed); let mut rb: Isaac64Rng = SeedableRng::from_seed(seed); assert!(ra.gen_ascii_chars() - .take(100) - .eq(rb.gen_ascii_chars().take(100))); + .take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] diff --git a/src/librand/rand_impls.rs b/src/librand/rand_impls.rs index 41ad089ecd235..b0d824da3ab47 100644 --- a/src/librand/rand_impls.rs +++ b/src/librand/rand_impls.rs @@ -203,10 +203,6 @@ tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L} impl Rand for Option { #[inline] fn rand(rng: &mut R) -> Option { - if rng.gen() { - Some(rng.gen()) - } else { - None - } + if rng.gen() { Some(rng.gen()) } else { None } } } diff --git a/src/librand/reseeding.rs b/src/librand/reseeding.rs index 48395c12fafeb..b8a65842e2ff5 100644 --- a/src/librand/reseeding.rs +++ b/src/librand/reseeding.rs @@ -138,7 +138,7 @@ mod tests { } } impl Default for Counter { - /// Constructs a `Counter` with initial value zero. + /// Constructs a `Counter` with initial value zero. fn default() -> Counter { Counter { i: 0 } } @@ -169,8 +169,8 @@ mod tests { let mut ra: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2)); let mut rb: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2)); assert!(ra.gen_ascii_chars() - .take(100) - .eq(rb.gen_ascii_chars().take(100))); + .take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test]