diff --git a/src/librand/chacha.rs b/src/librand/chacha.rs index cd099c69005f3..5fba44a1c38f1 100644 --- a/src/librand/chacha.rs +++ b/src/librand/chacha.rs @@ -10,7 +10,7 @@ //! The ChaCha random number generator. -use {Rng, SeedableRng, Rand}; +use {Rand, Rng, SeedableRng}; const KEY_WORDS: usize = 8; // 8 words for the 256-bit key const STATE_WORDS: usize = 16; @@ -216,7 +216,8 @@ mod tests { let s = ::test::rng().gen_iter::().take(8).collect::>(); let mut ra: ChaChaRng = SeedableRng::from_seed(&*s); let mut rb: ChaChaRng = SeedableRng::from_seed(&*s); - assert!(ra.gen_ascii_chars().take(100) + assert!(ra.gen_ascii_chars() + .take(100) .eq(rb.gen_ascii_chars().take(100))); } @@ -225,7 +226,8 @@ mod tests { let seed: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7]; let mut ra: ChaChaRng = SeedableRng::from_seed(seed); let mut rb: ChaChaRng = SeedableRng::from_seed(seed); - assert!(ra.gen_ascii_chars().take(100) + assert!(ra.gen_ascii_chars() + .take(100) .eq(rb.gen_ascii_chars().take(100))); } diff --git a/src/librand/distributions/exponential.rs b/src/librand/distributions/exponential.rs index 12dbbfdb0ed4d..5a8558efc0244 100644 --- a/src/librand/distributions/exponential.rs +++ b/src/librand/distributions/exponential.rs @@ -13,8 +13,8 @@ #[cfg(not(test))] // only necessary for no_std use FloatMath; -use {Rng, Rand}; -use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample}; +use {Rand, Rng}; +use distributions::{IndependentSample, Sample, ziggurat, ziggurat_tables}; /// A wrapper around an `f64` to generate Exp(1) random numbers. /// @@ -88,7 +88,7 @@ impl IndependentSample for Exp { #[cfg(test)] mod tests { - use distributions::{Sample, IndependentSample}; + use distributions::{IndependentSample, Sample}; use super::Exp; #[test] diff --git a/src/librand/distributions/gamma.rs b/src/librand/distributions/gamma.rs index cf48823656044..9ca13e85b5333 100644 --- a/src/librand/distributions/gamma.rs +++ b/src/librand/distributions/gamma.rs @@ -16,9 +16,9 @@ use self::ChiSquaredRepr::*; #[cfg(not(test))] // only necessary for no_std use FloatMath; -use {Rng, Open01}; +use {Open01, Rng}; use super::normal::StandardNormal; -use super::{IndependentSample, Sample, Exp}; +use super::{Exp, IndependentSample, Sample}; /// The Gamma distribution `Gamma(shape, scale)` distribution. /// @@ -291,8 +291,8 @@ impl IndependentSample for StudentT { #[cfg(test)] mod tests { - use distributions::{Sample, IndependentSample}; - use super::{ChiSquared, StudentT, FisherF}; + use distributions::{IndependentSample, Sample}; + use super::{ChiSquared, FisherF, StudentT}; #[test] fn test_chi_squared_one() { diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs index 2557d39c550f5..36c9f783ff5e0 100644 --- a/src/librand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -22,11 +22,11 @@ use core::num::Float; use core::marker::PhantomData; -use {Rng, Rand}; +use {Rand, Rng}; pub use self::range::Range; -pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT}; -pub use self::normal::{Normal, LogNormal}; +pub use self::gamma::{ChiSquared, FisherF, Gamma, StudentT}; +pub use self::normal::{LogNormal, Normal}; pub use self::exponential::Exp; pub mod range; @@ -266,8 +266,8 @@ fn ziggurat(rng: &mut R, #[cfg(test)] mod tests { - use {Rng, Rand}; - use super::{RandSample, WeightedChoice, Weighted, Sample, IndependentSample}; + use {Rand, Rng}; + use super::{IndependentSample, RandSample, Sample, Weighted, WeightedChoice}; #[derive(PartialEq, Debug)] struct ConstRand(usize); diff --git a/src/librand/distributions/normal.rs b/src/librand/distributions/normal.rs index 86840c568e018..811d5b14c7112 100644 --- a/src/librand/distributions/normal.rs +++ b/src/librand/distributions/normal.rs @@ -13,8 +13,8 @@ #[cfg(not(test))] // only necessary for no_std use FloatMath; -use {Rng, Rand, Open01}; -use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample}; +use {Open01, Rand, Rng}; +use distributions::{IndependentSample, Sample, ziggurat, ziggurat_tables}; /// A wrapper around an `f64` to generate N(0, 1) random numbers /// (a.k.a. a standard normal, or Gaussian). @@ -145,8 +145,8 @@ impl IndependentSample for LogNormal { #[cfg(test)] mod tests { - use distributions::{Sample, IndependentSample}; - use super::{Normal, LogNormal}; + use distributions::{IndependentSample, Sample}; + use super::{LogNormal, Normal}; #[test] fn test_normal() { diff --git a/src/librand/distributions/range.rs b/src/librand/distributions/range.rs index f94ef059dae8f..ba8554a979b89 100644 --- a/src/librand/distributions/range.rs +++ b/src/librand/distributions/range.rs @@ -14,7 +14,7 @@ use core::marker::Sized; use Rng; -use distributions::{Sample, IndependentSample}; +use distributions::{IndependentSample, Sample}; /// Sample values uniformly between two bounds. /// @@ -148,7 +148,7 @@ float_impl! { f64 } #[cfg(test)] mod tests { - use distributions::{Sample, IndependentSample}; + use distributions::{IndependentSample, Sample}; use super::Range; #[should_panic] diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index 28eff87bde3b7..e8cc7b5cc2dac 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -16,7 +16,7 @@ use core::slice; use core::iter::repeat; use core::num::Wrapping as w; -use {Rng, SeedableRng, Rand}; +use {Rand, Rng, SeedableRng}; type w32 = w; type w64 = w; @@ -591,14 +591,15 @@ mod tests { use std::prelude::v1::*; use {Rng, SeedableRng}; - use super::{IsaacRng, Isaac64Rng}; + use super::{Isaac64Rng, IsaacRng}; #[test] fn test_rng_32_rand_seeded() { let s = ::test::rng().gen_iter::().take(256).collect::>(); let mut ra: IsaacRng = SeedableRng::from_seed(&s[..]); let mut rb: IsaacRng = SeedableRng::from_seed(&s[..]); - assert!(ra.gen_ascii_chars().take(100) + assert!(ra.gen_ascii_chars() + .take(100) .eq(rb.gen_ascii_chars().take(100))); } #[test] @@ -606,7 +607,8 @@ mod tests { let s = ::test::rng().gen_iter::().take(256).collect::>(); let mut ra: Isaac64Rng = SeedableRng::from_seed(&s[..]); let mut rb: Isaac64Rng = SeedableRng::from_seed(&s[..]); - assert!(ra.gen_ascii_chars().take(100) + assert!(ra.gen_ascii_chars() + .take(100) .eq(rb.gen_ascii_chars().take(100))); } @@ -615,7 +617,8 @@ mod tests { let seed: &[_] = &[1, 23, 456, 7890, 12345]; let mut ra: IsaacRng = SeedableRng::from_seed(seed); let mut rb: IsaacRng = SeedableRng::from_seed(seed); - assert!(ra.gen_ascii_chars().take(100) + assert!(ra.gen_ascii_chars() + .take(100) .eq(rb.gen_ascii_chars().take(100))); } #[test] @@ -623,7 +626,8 @@ mod tests { let seed: &[_] = &[1, 23, 456, 7890, 12345]; let mut ra: Isaac64Rng = SeedableRng::from_seed(seed); let mut rb: Isaac64Rng = SeedableRng::from_seed(seed); - assert!(ra.gen_ascii_chars().take(100) + assert!(ra.gen_ascii_chars() + .take(100) .eq(rb.gen_ascii_chars().take(100))); } diff --git a/src/librand/lib.rs b/src/librand/lib.rs index d8517fb4c5714..c31a0ed53207d 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -47,10 +47,10 @@ use core::f64; use core::intrinsics; use core::marker::PhantomData; -pub use isaac::{IsaacRng, Isaac64Rng}; +pub use isaac::{Isaac64Rng, IsaacRng}; pub use chacha::ChaChaRng; -use distributions::{Range, IndependentSample}; +use distributions::{IndependentSample, Range}; use distributions::range::SampleRange; #[cfg(test)] @@ -67,7 +67,7 @@ mod rand_impls; // depend on libstd. This will go away when librand is integrated // into libstd. #[doc(hidden)] -trait FloatMath : Sized { +trait FloatMath: Sized { fn exp(self) -> Self; fn ln(self) -> Self; fn sqrt(self) -> Self; @@ -102,14 +102,14 @@ impl FloatMath for f64 { /// A type that can be randomly generated using an `Rng`. #[doc(hidden)] -pub trait Rand : Sized { +pub trait Rand: Sized { /// Generates a random instance of this type using the specified source of /// randomness. fn rand(rng: &mut R) -> Self; } /// A random number generator. -pub trait Rng : Sized { +pub trait Rng: Sized { /// Return the next random u32. /// /// This rarely needs to be called directly, prefer `r.gen()` to diff --git a/src/librand/reseeding.rs b/src/librand/reseeding.rs index db5e0213726d9..c7d560eb1f8e2 100644 --- a/src/librand/reseeding.rs +++ b/src/librand/reseeding.rs @@ -83,8 +83,8 @@ impl, Rsdr: Reseeder + Default> self.bytes_generated = 0; } - /// Create a new `ReseedingRng` from the given reseeder and - /// seed. This uses a default value for `generation_threshold`. +/// Create a new `ReseedingRng` from the given reseeder and +/// seed. This uses a default value for `generation_threshold`. fn from_seed((rsdr, seed): (Rsdr, S)) -> ReseedingRng { ReseedingRng { rng: SeedableRng::from_seed(seed), @@ -122,8 +122,8 @@ impl Default for ReseedWithDefault { mod tests { use std::prelude::v1::*; - use super::{ReseedingRng, ReseedWithDefault}; - use {SeedableRng, Rng}; + use super::{ReseedWithDefault, ReseedingRng}; + use {Rng, SeedableRng}; struct Counter { i: u32, @@ -166,7 +166,8 @@ mod tests { fn test_rng_seeded() { 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) + assert!(ra.gen_ascii_chars() + .take(100) .eq(rb.gen_ascii_chars().take(100))); }