Skip to content

Commit 16eeeac

Browse files
authored
Auto merge of rust-lang#37120 - srinivasreddy:librand, r=nrc
run rustfmt on librand
2 parents 753ea76 + ca39768 commit 16eeeac

File tree

5 files changed

+18
-30
lines changed

5 files changed

+18
-30
lines changed

src/librand/chacha.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ mod tests {
217217
let mut ra: ChaChaRng = SeedableRng::from_seed(&*s);
218218
let mut rb: ChaChaRng = SeedableRng::from_seed(&*s);
219219
assert!(ra.gen_ascii_chars()
220-
.take(100)
221-
.eq(rb.gen_ascii_chars().take(100)));
220+
.take(100)
221+
.eq(rb.gen_ascii_chars().take(100)));
222222
}
223223

224224
#[test]
@@ -227,8 +227,8 @@ mod tests {
227227
let mut ra: ChaChaRng = SeedableRng::from_seed(seed);
228228
let mut rb: ChaChaRng = SeedableRng::from_seed(seed);
229229
assert!(ra.gen_ascii_chars()
230-
.take(100)
231-
.eq(rb.gen_ascii_chars().take(100)));
230+
.take(100)
231+
.eq(rb.gen_ascii_chars().take(100)));
232232
}
233233

234234
#[test]

src/librand/distributions/mod.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,10 @@ fn ziggurat<R: Rng, P, Z>(rng: &mut R,
237237

238238
// u is either U(-1, 1) or U(0, 1) depending on if this is a
239239
// symmetric distribution or not.
240-
let u = if symmetric {
241-
2.0 * f - 1.0
242-
} else {
243-
f
244-
};
240+
let u = if symmetric { 2.0 * f - 1.0 } else { f };
245241
let x = u * x_tab[i];
246242

247-
let test_x = if symmetric {
248-
x.abs()
249-
} else {
250-
x
251-
};
243+
let test_x = if symmetric { x.abs() } else { x };
252244

253245
// algebraically equivalent to |u| < x_tab[i+1]/x_tab[i] (or u < x_tab[i+1]/x_tab[i])
254246
if test_x < x_tab[i + 1] {

src/librand/isaac.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -599,17 +599,17 @@ mod tests {
599599
let mut ra: IsaacRng = SeedableRng::from_seed(&s[..]);
600600
let mut rb: IsaacRng = SeedableRng::from_seed(&s[..]);
601601
assert!(ra.gen_ascii_chars()
602-
.take(100)
603-
.eq(rb.gen_ascii_chars().take(100)));
602+
.take(100)
603+
.eq(rb.gen_ascii_chars().take(100)));
604604
}
605605
#[test]
606606
fn test_rng_64_rand_seeded() {
607607
let s = ::test::rng().gen_iter::<u64>().take(256).collect::<Vec<u64>>();
608608
let mut ra: Isaac64Rng = SeedableRng::from_seed(&s[..]);
609609
let mut rb: Isaac64Rng = SeedableRng::from_seed(&s[..]);
610610
assert!(ra.gen_ascii_chars()
611-
.take(100)
612-
.eq(rb.gen_ascii_chars().take(100)));
611+
.take(100)
612+
.eq(rb.gen_ascii_chars().take(100)));
613613
}
614614

615615
#[test]
@@ -618,17 +618,17 @@ mod tests {
618618
let mut ra: IsaacRng = SeedableRng::from_seed(seed);
619619
let mut rb: IsaacRng = SeedableRng::from_seed(seed);
620620
assert!(ra.gen_ascii_chars()
621-
.take(100)
622-
.eq(rb.gen_ascii_chars().take(100)));
621+
.take(100)
622+
.eq(rb.gen_ascii_chars().take(100)));
623623
}
624624
#[test]
625625
fn test_rng_64_seeded() {
626626
let seed: &[_] = &[1, 23, 456, 7890, 12345];
627627
let mut ra: Isaac64Rng = SeedableRng::from_seed(seed);
628628
let mut rb: Isaac64Rng = SeedableRng::from_seed(seed);
629629
assert!(ra.gen_ascii_chars()
630-
.take(100)
631-
.eq(rb.gen_ascii_chars().take(100)));
630+
.take(100)
631+
.eq(rb.gen_ascii_chars().take(100)));
632632
}
633633

634634
#[test]

src/librand/rand_impls.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,6 @@ tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L}
203203
impl<T: Rand> Rand for Option<T> {
204204
#[inline]
205205
fn rand<R: Rng>(rng: &mut R) -> Option<T> {
206-
if rng.gen() {
207-
Some(rng.gen())
208-
} else {
209-
None
210-
}
206+
if rng.gen() { Some(rng.gen()) } else { None }
211207
}
212208
}

src/librand/reseeding.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ mod tests {
138138
}
139139
}
140140
impl Default for Counter {
141-
/// Constructs a `Counter` with initial value zero.
141+
/// Constructs a `Counter` with initial value zero.
142142
fn default() -> Counter {
143143
Counter { i: 0 }
144144
}
@@ -169,8 +169,8 @@ mod tests {
169169
let mut ra: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2));
170170
let mut rb: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2));
171171
assert!(ra.gen_ascii_chars()
172-
.take(100)
173-
.eq(rb.gen_ascii_chars().take(100)));
172+
.take(100)
173+
.eq(rb.gen_ascii_chars().take(100)));
174174
}
175175

176176
#[test]

0 commit comments

Comments
 (0)