rust-itertools / itertools

Extra iterator adaptors, iterator methods, free functions, and macros.
https://docs.rs/itertools/
Apache License 2.0
2.72k stars 309 forks source link

Do not update max key/value pair on equal elements. #728

Closed ttsugriy closed 1 year ago

ttsugriy commented 1 year ago

This avoids the need to use negation and avoids max key/value pair updates for equal elements.

Also added a test coverage gap.

scottmcm commented 1 year ago

You might have realized this since you closed the PR, but https://doc.rust-lang.org/std/cmp/fn.max.html intentionally returns the second if they're Ordering::Equal (and min returns the first), so it's probably intentional the the max is the last one in the iterator if they're all equivalent.

ttsugriy commented 1 year ago

yes, sorry for the hassle @scottmcm and thank you for working on such an awesome project!