4 ms·
I think I'd be happier to see total_cmp anywhere that it's clear we want some consistent order and it's not important what the order actually is. The hand-roll
by tialaramex 4y ago
I think I'd be happier to see total_cmp anywhere that it's clear we want some consistent order and it's not important what the order actually is.
The hand-rolled solution risks inconsistency. Given the opportunity to pick the order, people are going to pick different orders, sometimes by mistake, and providing total_cmp fixes that.
I can see that in things which decided they should be Ord but internally have a f32 and so they need to implement the comparison themselves, total_cmp seems like it's almost always going to be the right choice for that unless partial_cmp with unwrap() is definitely correct and they're sure of it.