Open timothee-haudebourg opened 4 years ago
A Hash
trait implementation would also be nice.
Might be interesting to use noisy_float or something.
In JavaScript, JSON.stringify(NaN)
returns null
. I think having NaN
at all near JSON is just an error waiting to happen.
If the NaN issue is cleared up I'd love to implement this, it seems pretty simple.
NaN on Number
is here purely for conversions from f64
. I'm okay with it being removed (along with From
) as long as there is a conversion from f64
for JsonValue
that produces Null
for NaN floats (since that seems to be the expected behavior).
@PurpleMyst with the stuff mentioned above, if you want to submit a PR, go for it :).
I'm wondering why
Eq
is not implemented for theNumber
struct. At first, I thought it was becauseNumber
can also representNaN
for which we usually expect thatNaN != NaN
. However a rapid glance at the implementation showed me that in the implementation ofPartialEq
, we haveNaN == NaN
.Having
Eq
would be useful to useNumber
or evenJsonValue
in containers likeHashSet
.Also why do you need to represent NaN in
Number
? As far as I know there is no NaN in JSON, right?