Resolve unnecessary_map_or clippy lint

warning: this `map_or` can be simplified
       --> src/number.rs:123:28
        |
    123 |                     return self.n.parse::<f64>().ok().map_or(false, f64::is_finite);
        |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
        = note: `-W clippy::unnecessary-map-or` implied by `-W clippy::all`
        = help: to override `-W clippy::all` add `#[allow(clippy::unnecessary_map_or)]`
    help: use `is_some_and` instead
        |
    123 -                     return self.n.parse::<f64>().ok().map_or(false, f64::is_finite);
    123 +                     return self.n.parse::<f64>().ok().is_some_and(f64::is_finite);
        |
This commit is contained in:
David Tolnay 2026-02-08 12:54:44 -08:00
parent fde7faaad7
commit 6b8ceab565
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -120,7 +120,7 @@ impl Number {
{
for c in self.n.chars() {
if c == '.' || c == 'e' || c == 'E' {
return self.n.parse::<f64>().ok().map_or(false, f64::is_finite);
return self.n.parse::<f64>().ok().is_some_and(f64::is_finite);
}
}
false