rust/src/libcore
Mazdak Farrokhzad 0ac09aef84
Rollup merge of #62205 - timvermeulen:iter_order_by, r=KodrAus
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 #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 logic of `cmp` / `partial_cmp` / `eq` is moved to `cmp_by` / `partial_cmp_by` / `eq_by` respectively, changing `x.cmp(&y)` to `cmp(&x, &y)` in the `cmp` method where `cmp` is the given comparison function (and similar for `partial_cmp_by` and `eq_by`).
- `ne_by` / `lt_by` / `le_by` / `gt_by` / `ge_by` are each implemented in terms of one of the three methods above.
- The existing comparison methods are each forwarded to their `_by` counterpart, passing one of `Ord::cmp` / `PartialOrd::partial_cmp` / `PartialEq::eq` as the comparison function.

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.
2019-09-08 12:11:55 +02:00
..
benches Improve ptr_rotate performance, tests, and benchmarks 2019-08-06 10:42:48 -05:00
char remove XID and Pattern_White_Space unicode tables from libcore 2019-09-04 13:11:11 +03:00
fmt Add a "diagnostic item" scheme 2019-08-30 01:00:55 +02:00
future Use associated_type_bounds where applicable - closes #61738 2019-08-08 22:39:15 +02:00
hash Make built-in derives opaque macros 2019-08-17 08:59:36 +01:00
iter Add Iterator comparison methods that take a comparison function 2019-09-06 15:30:17 +02:00
mem Auto merge of #63575 - Centril:rollup-anlv9g5, r=Centril 2019-08-15 00:32:05 +00:00
num Auto merge of #63692 - iluuu1994:issue-49660, r=sfackler 2019-09-02 15:32:08 +00:00
ops Added an extra line to make the formatting conform to the rest of the document. 2019-08-24 13:38:09 +02:00
prelude Remove __rust_unstable_column 2019-08-15 22:58:57 +03:00
ptr Doc nit 2019-08-17 21:40:35 +02:00
slice Apply clippy::let_and_return suggestion 2019-08-22 12:02:02 +02:00
str Fix word repetition in str documentation 2019-08-31 17:38:23 +01:00
sync Remove unneeded feature attr from atomic integers doctests 2019-06-04 13:24:39 +00:00
task Provide map_ok and map_err method for Poll<Option<Result<T, E>>> 2019-08-13 15:15:33 +05:30
tests Rollup merge of #62205 - timvermeulen:iter_order_by, r=KodrAus 2019-09-08 12:11:55 +02:00
unicode it's more pythonic to use 'is not None' in python files 2019-09-06 15:14:25 +08:00
alloc.rs Fix clippy::clone_on_copy warnings 2019-07-18 15:14:56 +02:00
any.rs Handle cfg(bootstrap) throughout 2019-08-14 05:39:53 -04:00
array.rs FixedSizeArray: Add missing links in doc comments. 2019-08-01 20:24:05 +07:00
ascii.rs Implement Clone, Display for ascii::EscapeDefault 2019-08-09 22:45:06 -04:00
bool.rs Add tracking issue 2019-09-07 17:06:39 +01:00
borrow.rs be more direct about borrow requirenments 2019-04-03 11:41:24 +03:00
Cargo.toml bump libcore tests to rand 0.7 2019-08-04 14:50:32 +02:00
cell.rs Auto merge of #62748 - luca-barbieri:optimize-refcell-borrow, r=RalfJung 2019-07-27 09:32:44 +00:00
clone.rs Make built-in derives opaque macros 2019-08-17 08:59:36 +01:00
cmp.rs Fix doc links in std::cmp module 2019-09-04 13:52:28 +00:00
convert.rs Add missing links on AsRef trait 2019-08-29 16:04:13 +02:00
default.rs Make built-in derives opaque macros 2019-08-17 08:59:36 +01:00
ffi.rs Make VaListImpl<'f> invariant over the 'f lifetime 2019-07-14 18:14:15 -07:00
hint.rs Auto merge of #62891 - vext01:improve-black-box-docs, r=RalfJung,Centril,gnzlbg 2019-08-26 04:10:54 +00:00
internal_macros.rs std: Remove internal definitions of cfg_if! macro 2019-06-10 10:58:44 -07:00
intrinsics.rs rustbuild: work around the stdarch cfg(bootstrap) bug. 2019-08-16 20:12:10 +03:00
iter_private.rs Remove licenses 2018-12-25 21:08:33 -07:00
lib.rs Move libcore/bool/mod.rs to libcore/bool.rs 2019-09-07 17:04:19 +01:00
macros.rs Support "soft" feature-gating using a lint 2019-09-07 21:37:51 +03:00
marker.rs Make built-in derives opaque macros 2019-08-17 08:59:36 +01:00
option.rs Add missing examples for Option type 2019-08-30 10:38:11 +02:00
panic.rs libcore: deny more... 2019-04-19 01:37:12 +02:00
panicking.rs libcore: deny more... 2019-04-19 01:37:12 +02:00
pin.rs Stabilize pin_into_inner in 1.39.0 2019-08-28 23:59:46 +01:00
raw.rs Fix more tests after revert of rustdoc cfg(test) feature 2019-06-09 18:15:53 +01:00
result.rs Auto merge of #63166 - ksqsf:master, r=alexcrichton 2019-09-04 07:47:08 +00:00
time.rs fix tests 2019-07-30 16:41:03 +00:00
tuple.rs libcore => 2018 2019-04-18 14:47:35 +09:00
unit.rs libcore => 2018 2019-04-18 14:47:35 +09:00