Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run rustfmt on librand #37120

Merged
merged 1 commit into from
Oct 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/librand/chacha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down
12 changes: 2 additions & 10 deletions src/librand/distributions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,10 @@ fn ziggurat<R: Rng, P, Z>(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] {
Expand Down
16 changes: 8 additions & 8 deletions src/librand/isaac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,17 +599,17 @@ 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() {
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)
.eq(rb.gen_ascii_chars().take(100)));
.take(100)
.eq(rb.gen_ascii_chars().take(100)));
}

#[test]
Expand All @@ -618,17 +618,17 @@ 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() {
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)
.eq(rb.gen_ascii_chars().take(100)));
.take(100)
.eq(rb.gen_ascii_chars().take(100)));
}

#[test]
Expand Down
6 changes: 1 addition & 5 deletions src/librand/rand_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,6 @@ tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L}
impl<T: Rand> Rand for Option<T> {
#[inline]
fn rand<R: Rng>(rng: &mut R) -> Option<T> {
if rng.gen() {
Some(rng.gen())
} else {
None
}
if rng.gen() { Some(rng.gen()) } else { None }
}
}
6 changes: 3 additions & 3 deletions src/librand/reseeding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down Expand Up @@ -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]
Expand Down