mirror of
https://github.com/async-rs/async-std.git
synced 2025-02-28 15:19:41 +00:00
fix clippy::comparison_chain
This commit is contained in:
parent
c9d958d309
commit
7c293d37f7
1 changed files with 5 additions and 6 deletions
|
@ -111,6 +111,7 @@ fn next_interval(prev: Instant, now: Instant, interval: Duration) -> Instant {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::next_interval;
|
||||
use std::cmp::Ordering;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
struct Timeline(Instant);
|
||||
|
@ -134,12 +135,10 @@ mod test {
|
|||
// The math around Instant/Duration isn't 100% precise due to rounding
|
||||
// errors, see #249 for more info
|
||||
fn almost_eq(a: Instant, b: Instant) -> bool {
|
||||
if a == b {
|
||||
true
|
||||
} else if a > b {
|
||||
a - b < Duration::from_millis(1)
|
||||
} else {
|
||||
b - a < Duration::from_millis(1)
|
||||
match a.cmp(&b) {
|
||||
Ordering::Equal => true,
|
||||
Ordering::Greater => a - b < Duration::from_millis(1),
|
||||
Ordering::Less => b - a < Duration::from_millis(1),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue