ir_remote/is_around.rs
1use std::time::Duration;
2
3pub trait IsAround {
4 fn is_around(&self, other: Self, error: f64) -> bool;
5}
6
7impl IsAround for Duration {
8 fn is_around(&self, other: Self, error: f64) -> bool {
9 let lower_bound = other.mul_f64(1.0 - error);
10 let upper_bound = other.mul_f64(1.0 + error);
11 self >= &lower_bound && self <= &upper_bound
12 }
13}