@@ -61,14 +61,14 @@ impl PartialEq for Constant {
61
61
( & Constant :: F64 ( l) , & Constant :: F64 ( r) ) => {
62
62
// we want `Fw32 == FwAny` and `FwAny == Fw64`, by transitivity we must have
63
63
// `Fw32 == Fw64` so don’t compare them
64
- // mem::transmute is required to catch non-matching 0.0, -0.0, and NaNs
65
- unsafe { mem :: transmute :: < f64 , u64 > ( l ) == mem :: transmute :: < f64 , u64 > ( r ) }
64
+ // to_bits is required to catch non-matching 0.0, -0.0, and NaNs
65
+ l . to_bits ( ) == r . to_bits ( )
66
66
} ,
67
67
( & Constant :: F32 ( l) , & Constant :: F32 ( r) ) => {
68
68
// we want `Fw32 == FwAny` and `FwAny == Fw64`, by transitivity we must have
69
69
// `Fw32 == Fw64` so don’t compare them
70
- // mem::transmute is required to catch non-matching 0.0, -0.0, and NaNs
71
- unsafe { mem :: transmute :: < f64 , u64 > ( f64 :: from ( l) ) == mem :: transmute :: < f64 , u64 > ( f64 :: from ( r) ) }
70
+ // to_bits is required to catch non-matching 0.0, -0.0, and NaNs
71
+ f64:: from ( l) . to_bits ( ) == f64:: from ( r) . to_bits ( )
72
72
} ,
73
73
( & Constant :: Bool ( l) , & Constant :: Bool ( r) ) => l == r,
74
74
( & Constant :: Vec ( ref l) , & Constant :: Vec ( ref r) ) | ( & Constant :: Tuple ( ref l) , & Constant :: Tuple ( ref r) ) => {
@@ -99,10 +99,10 @@ impl Hash for Constant {
99
99
i. hash ( state) ;
100
100
} ,
101
101
Constant :: F32 ( f) => {
102
- unsafe { mem :: transmute :: < f64 , u64 > ( f64 :: from ( f) ) } . hash ( state) ;
102
+ f64:: from ( f) . to_bits ( ) . hash ( state) ;
103
103
} ,
104
104
Constant :: F64 ( f) => {
105
- unsafe { mem :: transmute :: < f64 , u64 > ( f ) } . hash ( state) ;
105
+ f . to_bits ( ) . hash ( state) ;
106
106
} ,
107
107
Constant :: Bool ( b) => {
108
108
b. hash ( state) ;
0 commit comments