pub trait CloseTo<T, U: Into<T>> {
// Required methods
fn close_to(&self, other: U, precision: i32) -> (bool, T, T);
fn far_from(&self, other: U, precision: i32) -> (bool, T, T);
}Expand description
Trait to determine if two decimals are equal to a specified precision. Implemented in float type by default.
2つの小数が指定した精度で等しいかどうかを判定するトレイト。 デフォルトでfloat型に実装されている。
§Examples
use close_to::CloseTo;
let (is_close, ..) = 1.0.close_to(1.0001, 3);
assert!(is_close);
assert!(1.0.far_from(1.0001, 4).0);