File tree Expand file tree Collapse file tree 2 files changed +6
-20
lines changed
Expand file tree Collapse file tree 2 files changed +6
-20
lines changed Original file line number Diff line number Diff line change @@ -420,21 +420,11 @@ impl Hashable for PyComplex {
420420 fn hash ( zelf : & crate :: Py < Self > , _vm : & VirtualMachine ) -> PyResult < hash:: PyHash > {
421421 let value = zelf. value ;
422422
423- let re_hash = ( match hash:: hash_float ( value. re ) {
424- Some ( value) => Some ( value) ,
425- None => Some ( hash:: hash_pointer (
426- zelf as * const _ as * const std:: ffi:: c_void ,
427- ) ) ,
428- } )
429- . unwrap ( ) ;
423+ let re_hash = hash:: hash_float ( value. re )
424+ . unwrap_or_else ( || hash:: hash_pointer ( zelf as * const _ as * const std:: ffi:: c_void ) ) ;
430425
431- let im_hash = ( match hash:: hash_float ( value. im ) {
432- Some ( value) => Some ( value) ,
433- None => Some ( hash:: hash_pointer (
434- zelf as * const _ as * const std:: ffi:: c_void ,
435- ) ) ,
436- } )
437- . unwrap ( ) ;
426+ let im_hash = hash:: hash_float ( value. im )
427+ . unwrap_or_else ( || hash:: hash_pointer ( zelf as * const _ as * const std:: ffi:: c_void ) ) ;
438428
439429 let Wrapping ( ret) = Wrapping ( re_hash) + Wrapping ( im_hash) * Wrapping ( hash:: IMAG ) ;
440430 Ok ( hash:: fix_sentinel ( ret) )
Original file line number Diff line number Diff line change @@ -539,12 +539,8 @@ impl Comparable for PyFloat {
539539impl Hashable for PyFloat {
540540 #[ inline]
541541 fn hash ( zelf : & crate :: Py < Self > , _vm : & VirtualMachine ) -> PyResult < hash:: PyHash > {
542- match hash:: hash_float ( zelf. to_f64 ( ) ) {
543- Some ( value) => Ok ( value) ,
544- None => Ok ( hash:: hash_pointer (
545- zelf as * const _ as * const std:: ffi:: c_void ,
546- ) ) ,
547- }
542+ Ok ( hash:: hash_float ( zelf. to_f64 ( ) )
543+ . unwrap_or_else ( || hash:: hash_pointer ( zelf as * const _ as * const libc:: c_void ) ) )
548544 }
549545}
550546
You can’t perform that action at this time.
0 commit comments