Rust people are so weirdly invested in their Eq/PartialEq mistake that they keep adding new things under it, like StructuralEq/StructuralPartialEq.
Hint: If it worked, you wouldn't need to keep changing it.
[#]rust
=> More informations about this toot | More toots from soc@chaos.social
@soc I’ve been using Rust for nearly a decade and I still have no idea what the hell that was.
=> More informations about this toot | More toots from teotwaki@mastodon.online
@teotwaki Some follow-up discussion happened in https://chaos.social/@soc/113027993190371352 fwiw.
=> More informations about this toot | More toots from soc@chaos.social
@teotwaki TL;DR: Floats, like many other types, have more than one order.
But in #Rust Eq/PartialEq (and Ord/PartialOrd) are linked, so you have to pick one order, despite technically having two traits available.
=> More informations about this toot | More toots from soc@chaos.social
@soc What is the mistake?
=> More informations about this toot | More toots from saethlin@hachyderm.io
@saethlin Not having a free-standing trait for total order.
Eq being a marker trait subtyping PartialEq is cute ("look, we know math"), but I'm not aware of a single practical application of it, e. g.
"our algorithm is x% faster, because we exploit knowing that type T is not only a PartialEq, but an Eq".
On the downside, we have this inconsistency in the standard library where some collections do not support floating-point values at all, and others accept them but fail at runtime.
=> More informations about this toot | More toots from soc@chaos.social
@soc Which collections fail at runtime?
=> More informations about this toot | More toots from saethlin@hachyderm.io
@saethlin Anything that constrains contains
to PartialEq
let nan = 0.0/0.0;
let slc = [nan];
let vec = vec!(nan);
let rng = nan .. nan;
slc.contains(&nan);
vec.contains(&nan);
rng.contains(&nan);
leads to x is not in collection of x for some values of x.
It's fine to have a method for "does this value think that, according to its own domain-specific rules, some value in this collection is equal to itself" – but certainly not as its primary&only lookup function.
=> More informations about this toot | More toots from soc@chaos.social This content has been proxied by September (3851b).Proxy Information
text/gemini