Only show methods that appear in impl blocks in the Implementors sections of trait doc pages by ebarnard · Pull Request #61505 · rust-lang/rust (original) (raw)

Add Iterator comparison methods that take a comparison function

This PR adds Iterator::{cmp_by, partial_cmp_by, eq_by, ne_by, lt_by, le_by, gt_by, ge_by}. We already have Iterator::{cmp, partial_cmp, ...} which are less general (but not any simpler) than the ones I'm proposing here.

I'm submitting this PR now because rust-lang#61505 has been merged, so this change should not have a noticeable effect on the Iterator docs page size.

The diff is quite messy, here's what I changed:

The corresponding _by_key methods aren't included because they're not as fundamental as the _by methods and can easily be implemented in terms of them. Is that reasonable, or would adding the _by_key methods be desirable for the sake of completeness?

I didn't add any tests – I couldn't think of any that weren't already covered by our existing tests. Let me know if there's a particular test that would be useful to add.