rust/src/libcore/tests
bors 5349e69ae2 Auto merge of #64047 - timvermeulen:cmp_min_max_by, r=cuviper
Add `cmp::{min_by, min_by_key, max_by, max_by_key}`

This adds the following functions to `core::cmp`:

- `min_by`
- `min_by_key`
- `max_by`
- `max_by_key`

`min_by` and `max_by` are somewhat trivial to implement, but not entirely because `min_by` returns the first value in case the two are equal (and `max_by` the second). `min` and `max` can be implemented in terms of `min_by` and `max_by`, but not as easily the other way around.

To give an example of why I think these functions could be useful: the `Iterator::{min_by, min_by_key, max_by, max_by_key}` methods all currently hard-code the behavior mentioned above which is an ever so small duplication of logic. If we delegate them to `cmp::{min_by, max_by}` methods instead, we get the correct behavior for free. (edit: this is now included in the PR)

I added `min_by_key` / `max_by_key` for consistency's sake but I wouldn't mind removing them. I don't have a particular use case in mind for them, and `min_by` / `max_by` seem to be more useful.

Tracking issue: #64460
2019-09-21 04:21:25 +00:00
..
fmt Rollup merge of #60458 - KodrAus:debug_map_entry, r=alexcrichton 2019-07-09 04:52:35 +02:00
hash review or fix remaining miri failures in libcore 2019-02-13 18:21:13 +01:00
num Miri is really slow 2019-08-09 11:18:40 +02:00
alloc.rs Add const_unchecked_layout test to libcore/tests 2019-05-14 09:41:50 +02:00
any.rs Remove licenses 2018-12-25 21:08:33 -07:00
array.rs Remove licenses 2018-12-25 21:08:33 -07:00
ascii.rs Fix mismatching Kleene operators 2019-07-03 00:37:25 +02:00
atomic.rs Remove licenses 2018-12-25 21:08:33 -07:00
bool.rs Add bool::then and bool::then_with 2019-09-07 15:49:27 +01:00
cell.rs Deny rust_2018_idioms in libcore tests 2019-04-20 18:44:29 +02:00
char.rs Remove copy paste error in char tests 2019-02-27 14:44:20 +01:00
clone.rs Remove licenses 2018-12-25 21:08:33 -07:00
cmp.rs Add cmp::{min_by, min_by_key, max_by, max_by_key} 2019-09-14 21:52:08 +02:00
intrinsics.rs Remove licenses 2018-12-25 21:08:33 -07:00
iter.rs Rollup merge of #64121 - timvermeulen:iter_step_by_internal, r=scottmcm 2019-09-09 17:42:24 +02:00
lib.rs Add cmp::{min_by, min_by_key, max_by, max_by_key} 2019-09-14 21:52:08 +02:00
manually_drop.rs Remove licenses 2018-12-25 21:08:33 -07:00
mem.rs Remove licenses 2018-12-25 21:08:33 -07:00
nonzero.rs fixed tests again 2019-02-28 21:00:41 +01:00
ops.rs Import Bound in tests 2019-05-31 16:56:26 -05:00
option.rs renamed inner_deref feature's deref*() methods as_deref*() as per discussion https://github.com/rust-lang/rust/issues/50264 2019-07-18 15:17:30 +09:00
pattern.rs Fix mismatching Kleene operators 2019-07-03 00:37:25 +02:00
ptr.rs fix slice comparison 2019-08-05 15:30:08 +02:00
result.rs renamed inner_deref feature's deref*() methods as_deref*() as per discussion https://github.com/rust-lang/rust/issues/50264 2019-07-18 15:17:30 +09:00
slice.rs Rollup merge of #63265 - JohnTitor:implement-nth-back-for-chunksexactmut, r=scottmcm 2019-08-20 16:26:37 +02:00
str.rs Remove licenses 2018-12-25 21:08:33 -07:00
str_lossy.rs Remove licenses 2018-12-25 21:08:33 -07:00
time.rs Improve test output for libcore/time 2019-08-09 12:47:27 +05:30
tuple.rs Refactor tuple comparison tests 2019-03-25 13:00:57 -04:00