Skip to content

Commit

Permalink
Merge pull request #1197 from vks/clippy
Browse files Browse the repository at this point in the history
Fix clippy warnings
  • Loading branch information
vks authored Oct 21, 2021
2 parents 320acef + c1e859f commit fa6638b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion rand_core/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn fill_via_chunks<T: Observable>(src: &[T], dest: &mut [u8]) -> (usize, usize)
// This code is valid on all arches, but slower than the above:
let mut i = 0;
let mut iter = dest[..byte_len].chunks_exact_mut(size);
while let Some(chunk) = iter.next() {
for chunk in &mut iter {
chunk.copy_from_slice(src[i].to_le_bytes().as_ref());
i += 1;
}
Expand Down
4 changes: 2 additions & 2 deletions rand_distr/src/cauchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ where F: Float + FloatConst, Standard: Distribution<F>
mod test {
use super::*;

fn median(mut numbers: &mut [f64]) -> f64 {
sort(&mut numbers);
fn median(numbers: &mut [f64]) -> f64 {
sort(numbers);
let mid = numbers.len() / 2;
numbers[mid]
}
Expand Down
12 changes: 5 additions & 7 deletions rand_distr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,11 @@ mod test {
macro_rules! assert_almost_eq {
($a:expr, $b:expr, $prec:expr) => {
let diff = ($a - $b).abs();
if diff > $prec {
panic!(
"assertion failed: `abs(left - right) = {:.1e} < {:e}`, \
(left: `{}`, right: `{}`)",
diff, $prec, $a, $b
);
}
assert!(diff <= $prec,
"assertion failed: `abs(left - right) = {:.1e} < {:e}`, \
(left: `{}`, right: `{}`)",
diff, $prec, $a, $b
);
};
}
}
Expand Down
8 changes: 2 additions & 6 deletions rand_distr/tests/pdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ fn normal() {
for (&d, &e) in diff.iter().zip(expected_error.iter()) {
// Difference larger than 3 standard deviations or cutoff
let tol = (3. * e).max(1e-4);
if d > tol {
panic!("Difference = {} * tol", d / tol);
}
assert!(d <= tol, "Difference = {} * tol", d / tol);
}
}

Expand Down Expand Up @@ -176,8 +174,6 @@ fn skew_normal() {
for (&d, &e) in diff.iter().zip(expected_error.iter()) {
// Difference larger than 3 standard deviations or cutoff
let tol = (3. * e).max(1e-4);
if d > tol {
panic!("Difference = {} * tol", d / tol);
}
assert!(d <= tol, "Difference = {} * tol", d / tol);
}
}

0 comments on commit fa6638b

Please sign in to comment.