Skip to content

Commit

Permalink
Fix clippy::unnecessary_map_or warning
Browse files Browse the repository at this point in the history
```
error: this `map_or` is redundant
   --> src/duration.rs:637:9
    |
637 |         self.0.map_or(false, |this| this == *other)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(self.0 == Some(*other))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
    = note: `-D clippy::unnecessary-map-or` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::unnecessary_map_or)]`

error: this `map_or` is redundant
   --> src/instant.rs:163:9
    |
163 |         self.0.map_or(false, |this| this == *other)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(self.0 == Some(*other))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
```
  • Loading branch information
taiki-e committed Nov 17, 2024
1 parent f284322 commit f8c9a99
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ impl Duration {

impl PartialEq<time::Duration> for Duration {
fn eq(&self, other: &time::Duration) -> bool {
self.0.map_or(false, |this| this == *other)
self.0 == Some(*other)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/instant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl Instant {

impl PartialEq<time::Instant> for Instant {
fn eq(&self, other: &time::Instant) -> bool {
self.0.map_or(false, |this| this == *other)
self.0 == Some(*other)
}
}

Expand Down

0 comments on commit f8c9a99

Please sign in to comment.