-
Notifications
You must be signed in to change notification settings - Fork 13k
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
WIP comparators for pqueue #16047
WIP comparators for pqueue #16047
Conversation
@treeman @thestinger Any opinions on this? |
Ah sorry @gankro, been a bit busy. Here are some thoughts:
Generally the approach seems fine. Good job! Another idea could be to specify And later on when we standardize the library more, maybe |
Thanks for the feedback, @treeman!
|
FWIW, I think this should be postponed until we have reasonable unboxed closures; in particular #15067. |
@huonw: I agree that unboxed closures change this, and we should wait. Are there many open questions about how unboxed closures will behave/look, or is unboxed closures basically done? Assuming they take the from described in the RFC, I propose that the Comparator trait is still desirable for the following reasons:
|
@huonw should this be closed, or...? |
Yeah, I'm thinking we should close to avoid leaving this in the queue while it waits for unboxed closures. (Thanks for the work!) |
Rough draft of implementing comparators. WIP, just looking for general design discussion. Do not merge.
Notes:
Ord
is defined? Realistically I'd like to migrate a lot of std away from requiringOrd
, and instead requiring aComparator
(the former being trivial to move to the latter withNaturalOrdering
andRevOrdering
).default_type_params
, but it never seemed to do anything meaningful.Fn
, but as far as I can tell, the type they'd have to impl would be beFn<(&T, &T), Ordering>
, but the references need to have lifetimes, and I see no sane way to do that generically? Just feeding in 'a,'b everywhere certainly didn't work.min_heap
andmax_heap
as simply public functions, because they didn't make a lot of sense as static methods.max_heap
the default behaviour to match previous behaviour, but now that they're trivially interchangeable, I recommendmin_heap
be the default, since that matches sorting more closely.lt
method), but again I'd like to refactor them out into a separate module and use them more everywhere. In that context they should return a properOrd
. Might be some overhead right now from doingcmp(x,y) == Greater
, rather thangt(x, y)
.lt
/gt
/eq
/neq
automatically; desirable?Extend
is demanding that the comparator beDefault
, even though I see no reason for this to be the case.tests.test_iterator
from_vec_natural
if desired.