Closed m4rch3n1ng closed 1 week ago
on a side note, is there a reason to use f64::to_le_bytes()
over simply using f64::to_bits()
? the latter should be quicker (note: i haven't done any benchmarks), since the former calls f64::to_bits()
.
on a side note, is there a reason to use
f64::to_le_bytes()
over simply usingf64::to_bits()
? the latter should be quicker (note: i haven't done any benchmarks), since the former callsf64::to_bits()
.
It's just a wrapper then and will be optimised out by the compiler anyway with any level of optimisation enabled. Even if not, the cost would be insignificant. I wouldn't worry about it. :)
the current implementation of
Hash
forzvariant::Value
doesn't hold the property described in the rust rust standard library inHash
andEq
:implementing
Hash
for anf64
comes with a host of annoying issues, like being able to insert multipleVariant::F64(f64::NAN)
as keys into the map and not being able to retrieve them anymore, but it doesn't break this specific property, asf64::NAN
never evaluates totrue
with an==
operation, so it still (technically) holds thek1 == k2 -> hash(k1) == hash(k2)
property.this fixes the
Hash
andEq
property by hashing0.
and-0.
the same way.