Skip to content

Commit abb79cb

Browse files
committed
update FuzzyEq to explicit self
1 parent 5297520 commit abb79cb

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/libstd/cmp.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,30 @@ use core::float;
1818
const fuzzy_epsilon: float = 1.0e-6;
1919

2020
pub trait FuzzyEq {
21-
pure fn fuzzy_eq(other: &self) -> bool;
21+
pure fn fuzzy_eq(&self, other: &self) -> bool;
2222
}
2323

2424
impl float: FuzzyEq {
25-
pure fn fuzzy_eq(other: &float) -> bool {
26-
return float::abs(self - *other) < fuzzy_epsilon;
25+
pure fn fuzzy_eq(&self, other: &float) -> bool {
26+
float::abs(*self - *other) < fuzzy_epsilon
2727
}
2828
}
2929

3030
impl f32: FuzzyEq {
31-
pure fn fuzzy_eq(other: &f32) -> bool {
32-
return f32::abs(self - *other) < (fuzzy_epsilon as f32);
31+
pure fn fuzzy_eq(&self, other: &f32) -> bool {
32+
f32::abs(*self - *other) < (fuzzy_epsilon as f32)
3333
}
3434
}
3535

3636
impl f64: FuzzyEq {
37-
pure fn fuzzy_eq(other: &f64) -> bool {
38-
return f64::abs(self - *other) < (fuzzy_epsilon as f64);
37+
pure fn fuzzy_eq(&self, other: &f64) -> bool {
38+
f64::abs(*self - *other) < (fuzzy_epsilon as f64)
3939
}
4040
}
4141

4242
#[test]
4343
fn test_fuzzy_equals() {
44-
assert ((&1.0).fuzzy_eq(&1.0));
45-
assert ((&1.0f32).fuzzy_eq(&1.0f32));
46-
assert ((&1.0f64).fuzzy_eq(&1.0f64));
44+
assert (&1.0).fuzzy_eq(&1.0);
45+
assert (&1.0f32).fuzzy_eq(&1.0f32);
46+
assert (&1.0f64).fuzzy_eq(&1.0f64);
4747
}
48-

0 commit comments

Comments
 (0)