Fix parameter order for _by()
variants of min
/ max
/ minmax
in std::cmp
by miried · Pull Request #139357 · rust-lang/rust (original) (raw)
I just want to emphasize that violating duality like this is already explicitly called out as "a logic error" in the trait documentation, and thus anyone writing things like this should expect that their garbage in will result in garbage out in various situations.
It's ok if we want to give something stronger for these functions, since we know that they only need one check (to the extent that the _by
ones use FnOnce
), but this should not be considered a more general guarantee about the order in which comparisons will be done in the library.
Also, this was an intentional change, since historically lt
has worked better than le
, as seen by things like #106107.
Hopefully it's better now, as a bunch of work has happened in rust and LLVM to try to improve things, but...