Skip to content

Commit e0728d4

Browse files
committed
implement fuzzy_eq with fuzzy_eq_eps
1 parent fce6446 commit e0728d4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/libstd/cmp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -24,7 +24,7 @@ pub trait FuzzyEq {
2424

2525
impl float: FuzzyEq {
2626
pure fn fuzzy_eq(&self, other: &float) -> bool {
27-
float::abs(*self - *other) < fuzzy_epsilon
27+
self.fuzzy_eq_eps(other, fuzzy_epsilon)
2828
}
2929

3030
pure fn fuzzy_eq_eps(&self, other: &float, epsilon: &float) -> bool {
@@ -34,7 +34,7 @@ impl float: FuzzyEq {
3434

3535
impl f32: FuzzyEq {
3636
pure fn fuzzy_eq(&self, other: &f32) -> bool {
37-
f32::abs(*self - *other) < (fuzzy_epsilon as f32)
37+
self.fuzzy_eq_eps(other, fuzzy_epsilon as f32)
3838
}
3939

4040
pure fn fuzzy_eq_eps(&self, other: &f32, epsilon: &f32) -> bool {
@@ -44,7 +44,7 @@ impl f32: FuzzyEq {
4444

4545
impl f64: FuzzyEq {
4646
pure fn fuzzy_eq(&self, other: &f64) -> bool {
47-
f64::abs(*self - *other) < (fuzzy_epsilon as f64)
47+
self.fuzzy_eq_eps(other, fuzzy_epsilon as f64)
4848
}
4949

5050
pure fn fuzzy_eq_eps(&self, other: &f64, epsilon: &f64) -> bool {

0 commit comments

Comments
 (0)