Skip to content

Commit 72baa41

Browse files
committed
run rustfmt on librand folder
1 parent 90d9a51 commit 72baa41

File tree

9 files changed

+44
-37
lines changed

9 files changed

+44
-37
lines changed

src/librand/chacha.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! The ChaCha random number generator.
1212
13-
use {Rng, SeedableRng, Rand};
13+
use {Rand, Rng, SeedableRng};
1414

1515
const KEY_WORDS: usize = 8; // 8 words for the 256-bit key
1616
const STATE_WORDS: usize = 16;
@@ -216,7 +216,8 @@ mod tests {
216216
let s = ::test::rng().gen_iter::<u32>().take(8).collect::<Vec<u32>>();
217217
let mut ra: ChaChaRng = SeedableRng::from_seed(&*s);
218218
let mut rb: ChaChaRng = SeedableRng::from_seed(&*s);
219-
assert!(ra.gen_ascii_chars().take(100)
219+
assert!(ra.gen_ascii_chars()
220+
.take(100)
220221
.eq(rb.gen_ascii_chars().take(100)));
221222
}
222223

@@ -225,7 +226,8 @@ mod tests {
225226
let seed: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7];
226227
let mut ra: ChaChaRng = SeedableRng::from_seed(seed);
227228
let mut rb: ChaChaRng = SeedableRng::from_seed(seed);
228-
assert!(ra.gen_ascii_chars().take(100)
229+
assert!(ra.gen_ascii_chars()
230+
.take(100)
229231
.eq(rb.gen_ascii_chars().take(100)));
230232
}
231233

src/librand/distributions/exponential.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#[cfg(not(test))] // only necessary for no_std
1414
use FloatMath;
1515

16-
use {Rng, Rand};
17-
use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
16+
use {Rand, Rng};
17+
use distributions::{IndependentSample, Sample, ziggurat, ziggurat_tables};
1818

1919
/// A wrapper around an `f64` to generate Exp(1) random numbers.
2020
///
@@ -88,7 +88,7 @@ impl IndependentSample<f64> for Exp {
8888

8989
#[cfg(test)]
9090
mod tests {
91-
use distributions::{Sample, IndependentSample};
91+
use distributions::{IndependentSample, Sample};
9292
use super::Exp;
9393

9494
#[test]

src/librand/distributions/gamma.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use self::ChiSquaredRepr::*;
1616
#[cfg(not(test))] // only necessary for no_std
1717
use FloatMath;
1818

19-
use {Rng, Open01};
19+
use {Open01, Rng};
2020
use super::normal::StandardNormal;
21-
use super::{IndependentSample, Sample, Exp};
21+
use super::{Exp, IndependentSample, Sample};
2222

2323
/// The Gamma distribution `Gamma(shape, scale)` distribution.
2424
///
@@ -291,8 +291,8 @@ impl IndependentSample<f64> for StudentT {
291291

292292
#[cfg(test)]
293293
mod tests {
294-
use distributions::{Sample, IndependentSample};
295-
use super::{ChiSquared, StudentT, FisherF};
294+
use distributions::{IndependentSample, Sample};
295+
use super::{ChiSquared, FisherF, StudentT};
296296

297297
#[test]
298298
fn test_chi_squared_one() {

src/librand/distributions/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ use core::num::Float;
2222

2323
use core::marker::PhantomData;
2424

25-
use {Rng, Rand};
25+
use {Rand, Rng};
2626

2727
pub use self::range::Range;
28-
pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT};
29-
pub use self::normal::{Normal, LogNormal};
28+
pub use self::gamma::{ChiSquared, FisherF, Gamma, StudentT};
29+
pub use self::normal::{LogNormal, Normal};
3030
pub use self::exponential::Exp;
3131

3232
pub mod range;
@@ -266,8 +266,8 @@ fn ziggurat<R: Rng, P, Z>(rng: &mut R,
266266

267267
#[cfg(test)]
268268
mod tests {
269-
use {Rng, Rand};
270-
use super::{RandSample, WeightedChoice, Weighted, Sample, IndependentSample};
269+
use {Rand, Rng};
270+
use super::{IndependentSample, RandSample, Sample, Weighted, WeightedChoice};
271271

272272
#[derive(PartialEq, Debug)]
273273
struct ConstRand(usize);

src/librand/distributions/normal.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#[cfg(not(test))] // only necessary for no_std
1414
use FloatMath;
1515

16-
use {Rng, Rand, Open01};
17-
use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
16+
use {Open01, Rand, Rng};
17+
use distributions::{IndependentSample, Sample, ziggurat, ziggurat_tables};
1818

1919
/// A wrapper around an `f64` to generate N(0, 1) random numbers
2020
/// (a.k.a. a standard normal, or Gaussian).
@@ -145,8 +145,8 @@ impl IndependentSample<f64> for LogNormal {
145145

146146
#[cfg(test)]
147147
mod tests {
148-
use distributions::{Sample, IndependentSample};
149-
use super::{Normal, LogNormal};
148+
use distributions::{IndependentSample, Sample};
149+
use super::{LogNormal, Normal};
150150

151151
#[test]
152152
fn test_normal() {

src/librand/distributions/range.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use core::marker::Sized;
1616
use Rng;
17-
use distributions::{Sample, IndependentSample};
17+
use distributions::{IndependentSample, Sample};
1818

1919
/// Sample values uniformly between two bounds.
2020
///
@@ -148,7 +148,7 @@ float_impl! { f64 }
148148

149149
#[cfg(test)]
150150
mod tests {
151-
use distributions::{Sample, IndependentSample};
151+
use distributions::{IndependentSample, Sample};
152152
use super::Range;
153153

154154
#[should_panic]

src/librand/isaac.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use core::slice;
1616
use core::iter::repeat;
1717
use core::num::Wrapping as w;
1818

19-
use {Rng, SeedableRng, Rand};
19+
use {Rand, Rng, SeedableRng};
2020

2121
type w32 = w<u32>;
2222
type w64 = w<u64>;
@@ -591,22 +591,24 @@ mod tests {
591591
use std::prelude::v1::*;
592592

593593
use {Rng, SeedableRng};
594-
use super::{IsaacRng, Isaac64Rng};
594+
use super::{Isaac64Rng, IsaacRng};
595595

596596
#[test]
597597
fn test_rng_32_rand_seeded() {
598598
let s = ::test::rng().gen_iter::<u32>().take(256).collect::<Vec<u32>>();
599599
let mut ra: IsaacRng = SeedableRng::from_seed(&s[..]);
600600
let mut rb: IsaacRng = SeedableRng::from_seed(&s[..]);
601-
assert!(ra.gen_ascii_chars().take(100)
601+
assert!(ra.gen_ascii_chars()
602+
.take(100)
602603
.eq(rb.gen_ascii_chars().take(100)));
603604
}
604605
#[test]
605606
fn test_rng_64_rand_seeded() {
606607
let s = ::test::rng().gen_iter::<u64>().take(256).collect::<Vec<u64>>();
607608
let mut ra: Isaac64Rng = SeedableRng::from_seed(&s[..]);
608609
let mut rb: Isaac64Rng = SeedableRng::from_seed(&s[..]);
609-
assert!(ra.gen_ascii_chars().take(100)
610+
assert!(ra.gen_ascii_chars()
611+
.take(100)
610612
.eq(rb.gen_ascii_chars().take(100)));
611613
}
612614

@@ -615,15 +617,17 @@ mod tests {
615617
let seed: &[_] = &[1, 23, 456, 7890, 12345];
616618
let mut ra: IsaacRng = SeedableRng::from_seed(seed);
617619
let mut rb: IsaacRng = SeedableRng::from_seed(seed);
618-
assert!(ra.gen_ascii_chars().take(100)
620+
assert!(ra.gen_ascii_chars()
621+
.take(100)
619622
.eq(rb.gen_ascii_chars().take(100)));
620623
}
621624
#[test]
622625
fn test_rng_64_seeded() {
623626
let seed: &[_] = &[1, 23, 456, 7890, 12345];
624627
let mut ra: Isaac64Rng = SeedableRng::from_seed(seed);
625628
let mut rb: Isaac64Rng = SeedableRng::from_seed(seed);
626-
assert!(ra.gen_ascii_chars().take(100)
629+
assert!(ra.gen_ascii_chars()
630+
.take(100)
627631
.eq(rb.gen_ascii_chars().take(100)));
628632
}
629633

src/librand/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ use core::f64;
4747
use core::intrinsics;
4848
use core::marker::PhantomData;
4949

50-
pub use isaac::{IsaacRng, Isaac64Rng};
50+
pub use isaac::{Isaac64Rng, IsaacRng};
5151
pub use chacha::ChaChaRng;
5252

53-
use distributions::{Range, IndependentSample};
53+
use distributions::{IndependentSample, Range};
5454
use distributions::range::SampleRange;
5555

5656
#[cfg(test)]
@@ -67,7 +67,7 @@ mod rand_impls;
6767
// depend on libstd. This will go away when librand is integrated
6868
// into libstd.
6969
#[doc(hidden)]
70-
trait FloatMath : Sized {
70+
trait FloatMath: Sized {
7171
fn exp(self) -> Self;
7272
fn ln(self) -> Self;
7373
fn sqrt(self) -> Self;
@@ -102,14 +102,14 @@ impl FloatMath for f64 {
102102

103103
/// A type that can be randomly generated using an `Rng`.
104104
#[doc(hidden)]
105-
pub trait Rand : Sized {
105+
pub trait Rand: Sized {
106106
/// Generates a random instance of this type using the specified source of
107107
/// randomness.
108108
fn rand<R: Rng>(rng: &mut R) -> Self;
109109
}
110110

111111
/// A random number generator.
112-
pub trait Rng : Sized {
112+
pub trait Rng: Sized {
113113
/// Return the next random u32.
114114
///
115115
/// This rarely needs to be called directly, prefer `r.gen()` to

src/librand/reseeding.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ impl<S, R: SeedableRng<S>, Rsdr: Reseeder<R> + Default>
8383
self.bytes_generated = 0;
8484
}
8585

86-
/// Create a new `ReseedingRng` from the given reseeder and
87-
/// seed. This uses a default value for `generation_threshold`.
86+
/// Create a new `ReseedingRng` from the given reseeder and
87+
/// seed. This uses a default value for `generation_threshold`.
8888
fn from_seed((rsdr, seed): (Rsdr, S)) -> ReseedingRng<R, Rsdr> {
8989
ReseedingRng {
9090
rng: SeedableRng::from_seed(seed),
@@ -122,8 +122,8 @@ impl Default for ReseedWithDefault {
122122
mod tests {
123123
use std::prelude::v1::*;
124124

125-
use super::{ReseedingRng, ReseedWithDefault};
126-
use {SeedableRng, Rng};
125+
use super::{ReseedWithDefault, ReseedingRng};
126+
use {Rng, SeedableRng};
127127

128128
struct Counter {
129129
i: u32,
@@ -166,7 +166,8 @@ mod tests {
166166
fn test_rng_seeded() {
167167
let mut ra: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2));
168168
let mut rb: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2));
169-
assert!(ra.gen_ascii_chars().take(100)
169+
assert!(ra.gen_ascii_chars()
170+
.take(100)
170171
.eq(rb.gen_ascii_chars().take(100)));
171172
}
172173

0 commit comments

Comments
 (0)