Skip to content

Commit

Permalink
Merge pull request #127 from cuviper/lints
Browse files Browse the repository at this point in the history
Fix a few miscellaneous lints
  • Loading branch information
cuviper committed May 7, 2024
2 parents a52a8e1 + 67398e3 commit c8c06ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
11 changes: 6 additions & 5 deletions src/crand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ fn test_rng() -> impl RngCore {
}

fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> {
Ok(self.fill_bytes(dest))
self.fill_bytes(dest);
Ok(())
}
}

Expand All @@ -94,7 +95,7 @@ fn generic_standard_f64() {
let mut rng = test_rng();
let dist = ComplexDistribution::new(Standard, Standard);
for _ in 0..100 {
let c: Complex<f64> = rng.sample(&dist);
let c: Complex<f64> = rng.sample(dist);
assert!(c.re >= 0.0 && c.re < 1.0);
assert!(c.im >= 0.0 && c.im < 1.0);
}
Expand All @@ -110,7 +111,7 @@ fn generic_uniform_f64() {
let dist = ComplexDistribution::new(re, im);
for _ in 0..100 {
// no type annotation required, since `Uniform` only produces one type.
let c = rng.sample(&dist);
let c = rng.sample(dist);
assert!(c.re >= -100.0 && c.re < 0.0);
assert!(c.im >= 0.0 && c.im < 100.0);
}
Expand All @@ -125,7 +126,7 @@ fn generic_mixed_f64() {
let dist = ComplexDistribution::new(re, Standard);
for _ in 0..100 {
// no type annotation required, since `Uniform` only produces one type.
let c = rng.sample(&dist);
let c = rng.sample(dist);
assert!(c.re >= -100.0 && c.re < 0.0);
assert!(c.im >= 0.0 && c.im < 1.0);
}
Expand All @@ -141,7 +142,7 @@ fn generic_uniform_i32() {
let dist = ComplexDistribution::new(re, im);
for _ in 0..100 {
// no type annotation required, since `Uniform` only produces one type.
let c = rng.sample(&dist);
let c = rng.sample(dist);
assert!(c.re >= -100 && c.re < 0);
assert!(c.im >= 0 && c.im < 100);
}
Expand Down
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ impl<T: Clone + Num + Neg<Output = T>> Inv for Complex<T> {

#[inline]
fn inv(self) -> Self::Output {
(&self).inv()
Complex::inv(&self)
}
}

Expand All @@ -1015,7 +1015,7 @@ impl<'a, T: Clone + Num + Neg<Output = T>> Inv for &'a Complex<T> {

#[inline]
fn inv(self) -> Self::Output {
self.inv()
Complex::inv(self)
}
}

Expand Down Expand Up @@ -1390,7 +1390,6 @@ where
}
}

#[allow(deprecated)] // `trim_left_matches` and `trim_right_matches` since 1.33
fn from_str_generic<T, E, F>(s: &str, from: F) -> Result<Complex<T>, ParseComplexError<E>>
where
F: Fn(&str) -> Result<T, E>,
Expand All @@ -1412,8 +1411,8 @@ where
// ignore '+'/'-' if part of an exponent
if (c == b'+' || c == b'-') && !(p == b'e' || p == b'E') {
// trim whitespace around the separator
a = &s[..=i].trim_right_matches(char::is_whitespace);
b = &s[i + 2..].trim_left_matches(char::is_whitespace);
a = s[..=i].trim_end_matches(char::is_whitespace);
b = s[i + 2..].trim_start_matches(char::is_whitespace);
neg_b = c == b'-';

if b.is_empty() || (neg_b && b.starts_with('-')) {
Expand Down

0 comments on commit c8c06ae

Please sign in to comment.