File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -18,31 +18,30 @@ use core::float;
18
18
const fuzzy_epsilon: float = 1.0e-6 ;
19
19
20
20
pub trait FuzzyEq {
21
- pure fn fuzzy_eq ( other: & self ) -> bool ;
21
+ pure fn fuzzy_eq ( & self , other: & self ) -> bool ;
22
22
}
23
23
24
24
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
27
27
}
28
28
}
29
29
30
30
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 )
33
33
}
34
34
}
35
35
36
36
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 )
39
39
}
40
40
}
41
41
42
42
#[ test]
43
43
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 ) ;
47
47
}
48
-
You can’t perform that action at this time.
0 commit comments