Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

min_by requires Ord not PartialOrd #675

Closed
steveklabnik opened this issue Jan 21, 2015 · 2 comments
Closed

min_by requires Ord not PartialOrd #675

steveklabnik opened this issue Jan 21, 2015 · 2 comments
Labels
T-libs-api Relevant to the library API team, which will review and decide on the RFC.

Comments

@steveklabnik
Copy link
Member

Issue by neunenak
Tuesday Sep 30, 2014 at 06:15 GMT

For earlier discussion, see rust-lang/rust#17648

This issue was labelled with: A-iterators, A-libs, B-RFC in the Rust repository


It would be handy if Iterator::min_by required PartialOrd instead of Ord. This requirement makes it impossible to use with among other common types f32 and f64, which is annoying. I don't know if the best solution is to simply change the required trait to PartialOrd or to provide some other method min_by_partial_ord or something along those lines. The same reasoning should apply to Iterator::max_by

@jimblandy
Copy link

Possible revisions to max_by and min_by that would make this problem go away are being discussed in Rust issue 15311. Summary: "scoring" functions like the one expected by max_by have disadvantages; expecting a function that does the comparison and returns a bool or Ordering might work better.

@petrochenkov petrochenkov added the T-libs-api Relevant to the library API team, which will review and decide on the RFC. label Jan 29, 2018
@Centril
Copy link
Contributor

Centril commented Oct 7, 2018

I believe this is non-actionable now; and there's https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.min_by which doesn't require any T: Ord.

@Centril Centril closed this as completed Oct 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

4 participants