mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-11 16:15:03 +00:00
Remove deprecated modes from FuzzyEq in cmp.rs
This commit may require changes to the following Servo files: * rust-geom/matrix.rs * servo/platform/osmain.rs * rust-layers/layers.rs * rust-geom/matrix.rs
This commit is contained in:
parent
340a219290
commit
2580040995
@ -1,34 +1,36 @@
|
|||||||
#[deny(non_camel_case_types)];
|
#[deny(non_camel_case_types)];
|
||||||
|
#[forbid(deprecated_mode)];
|
||||||
|
#[forbid(deprecated_pattern)];
|
||||||
/// Additional general-purpose comparison functionality.
|
/// Additional general-purpose comparison functionality.
|
||||||
|
|
||||||
const fuzzy_epsilon: float = 1.0e-6;
|
const fuzzy_epsilon: float = 1.0e-6;
|
||||||
|
|
||||||
trait FuzzyEq {
|
trait FuzzyEq {
|
||||||
pure fn fuzzy_eq(&&other: self) -> bool;
|
pure fn fuzzy_eq(other: &self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl float: FuzzyEq {
|
impl float: FuzzyEq {
|
||||||
pure fn fuzzy_eq(&&other: float) -> bool {
|
pure fn fuzzy_eq(other: &float) -> bool {
|
||||||
return float::abs(self - other) < fuzzy_epsilon;
|
return float::abs(self - *other) < fuzzy_epsilon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl f32: FuzzyEq {
|
impl f32: FuzzyEq {
|
||||||
pure fn fuzzy_eq(&&other: f32) -> bool {
|
pure fn fuzzy_eq(other: &f32) -> bool {
|
||||||
return f32::abs(self - other) < (fuzzy_epsilon as f32);
|
return f32::abs(self - *other) < (fuzzy_epsilon as f32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl f64: FuzzyEq {
|
impl f64: FuzzyEq {
|
||||||
pure fn fuzzy_eq(&&other: f64) -> bool {
|
pure fn fuzzy_eq(other: &f64) -> bool {
|
||||||
return f64::abs(self - other) < (fuzzy_epsilon as f64);
|
return f64::abs(self - *other) < (fuzzy_epsilon as f64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fuzzy_equals() {
|
fn test_fuzzy_equals() {
|
||||||
assert ((1.0).fuzzy_eq(1.0));
|
assert ((&1.0).fuzzy_eq(&1.0));
|
||||||
assert ((1.0f32).fuzzy_eq(1.0f32));
|
assert ((&1.0f32).fuzzy_eq(&1.0f32));
|
||||||
assert ((1.0f64).fuzzy_eq(1.0f64));
|
assert ((&1.0f64).fuzzy_eq(&1.0f64));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user