Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for slice::sort_by_key #30423
Comments
alexcrichton
added
I-nominated
T-libs
B-unstable
labels
Dec 16, 2015
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
added
final-comment-period
and removed
I-nominated
labels
Dec 17, 2015
This comment has been minimized.
This comment has been minimized.
|
There is a function related to
|
This comment has been minimized.
This comment has been minimized.
|
An excellent point! I'll see if I can't add that soon to sneak it in for this FCP as well |
This comment has been minimized.
This comment has been minimized.
|
Hm actually, now that I think about it I'm not quite sure what the signature for fn binary_search_by_key<B, F>(&self, b: &B, f: F) -> Result<usize, usize>
where F: FnOnce(&Self::Item) -> B, B: Ord;Is that what you were thinking as well? |
This comment has been minimized.
This comment has been minimized.
|
Yes. I suggest renaming |
This comment has been minimized.
This comment has been minimized.
|
Hm this may actually be a case where I'm not sure the extra method may buy much, for example compare: slice.binary_search_by(|k| k.key.cmp(&val));
// vs
slice.binary_search_by_key(&val, |k| &k.key);The |
This comment has been minimized.
This comment has been minimized.
|
For search with closures that maybe the case, but for search with methods or functions s.sort_by_key(Point::x);
// this is more readable
s.binary_search_by_key(&1, Point::x);
// than this
s.binary_search_by(|p| p.x().cmp(&1)); |
This comment has been minimized.
This comment has been minimized.
|
Oh hm yeah, good point! |
This comment has been minimized.
This comment has been minimized.
|
The libs team discussed this recently and the decision was to stabilize |
This comment has been minimized.
This comment has been minimized.
|
Closed by #30943 |
alexcrichton
closed this
Jan 21, 2016
This comment has been minimized.
This comment has been minimized.
|
Should we open another issue for |
alexcrichton commentedDec 16, 2015
As-is on the tin, mirrors the recently-stabilized
min_by_keyandmax_by_keymethods onIterator.