Skip to content

Commit 7c293d3

Browse files
committed
fix clippy::comparison_chain
1 parent c9d958d commit 7c293d3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/stream/interval.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ fn next_interval(prev: Instant, now: Instant, interval: Duration) -> Instant {
111111
#[cfg(test)]
112112
mod test {
113113
use super::next_interval;
114+
use std::cmp::Ordering;
114115
use std::time::{Duration, Instant};
115116

116117
struct Timeline(Instant);
@@ -134,12 +135,10 @@ mod test {
134135
// The math around Instant/Duration isn't 100% precise due to rounding
135136
// errors, see #249 for more info
136137
fn almost_eq(a: Instant, b: Instant) -> bool {
137-
if a == b {
138-
true
139-
} else if a > b {
140-
a - b < Duration::from_millis(1)
141-
} else {
142-
b - a < Duration::from_millis(1)
138+
match a.cmp(&b) {
139+
Ordering::Equal => true,
140+
Ordering::Greater => a - b < Duration::from_millis(1),
141+
Ordering::Less => b - a < Duration::from_millis(1),
143142
}
144143
}
145144

0 commit comments

Comments
 (0)