run rustfmt on librand folder

This commit is contained in:
Srinivas Reddy Thatiparthy 2016-05-29 08:40:34 +05:30
parent 90d9a515af
commit 72baa41b88
9 changed files with 44 additions and 37 deletions

View File

@ -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::<u32>().take(8).collect::<Vec<u32>>();
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)));
}

View File

@ -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<f64> for Exp {
#[cfg(test)]
mod tests {
use distributions::{Sample, IndependentSample};
use distributions::{IndependentSample, Sample};
use super::Exp;
#[test]

View File

@ -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<f64> 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() {

View File

@ -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<R: Rng, P, Z>(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);

View File

@ -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<f64> 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() {

View File

@ -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]

View File

@ -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<u32>;
type w64 = w<u64>;
@ -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::<u32>().take(256).collect::<Vec<u32>>();
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::<u64>().take(256).collect::<Vec<u64>>();
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)));
}

View File

@ -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<R: Rng>(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

View File

@ -83,8 +83,8 @@ impl<S, R: SeedableRng<S>, Rsdr: Reseeder<R> + 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<R, Rsdr> {
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)));
}