-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3308 from killerswan/modes7
Remove deprecated modes
- Loading branch information
Showing
7 changed files
with
71 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
#[deny(non_camel_case_types)]; | ||
#[forbid(deprecated_mode)]; | ||
#[forbid(deprecated_pattern)]; | ||
/// Additional general-purpose comparison functionality. | ||
|
||
const fuzzy_epsilon: float = 1.0e-6; | ||
|
||
trait FuzzyEq { | ||
pure fn fuzzy_eq(&&other: self) -> bool; | ||
pure fn fuzzy_eq(other: &self) -> bool; | ||
} | ||
|
||
impl float: FuzzyEq { | ||
pure fn fuzzy_eq(&&other: float) -> bool { | ||
return float::abs(self - other) < fuzzy_epsilon; | ||
pure fn fuzzy_eq(other: &float) -> bool { | ||
return float::abs(self - *other) < fuzzy_epsilon; | ||
} | ||
} | ||
|
||
impl f32: FuzzyEq { | ||
pure fn fuzzy_eq(&&other: f32) -> bool { | ||
return f32::abs(self - other) < (fuzzy_epsilon as f32); | ||
pure fn fuzzy_eq(other: &f32) -> bool { | ||
return f32::abs(self - *other) < (fuzzy_epsilon as f32); | ||
} | ||
} | ||
|
||
impl f64: FuzzyEq { | ||
pure fn fuzzy_eq(&&other: f64) -> bool { | ||
return f64::abs(self - other) < (fuzzy_epsilon as f64); | ||
pure fn fuzzy_eq(other: &f64) -> bool { | ||
return f64::abs(self - *other) < (fuzzy_epsilon as f64); | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_fuzzy_equals() { | ||
assert ((1.0).fuzzy_eq(1.0)); | ||
assert ((1.0f32).fuzzy_eq(1.0f32)); | ||
assert ((1.0f64).fuzzy_eq(1.0f64)); | ||
assert ((&1.0).fuzzy_eq(&1.0)); | ||
assert ((&1.0f32).fuzzy_eq(&1.0f32)); | ||
assert ((&1.0f64).fuzzy_eq(&1.0f64)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters