rust/library/alloc/tests
bors b33e234155 Auto merge of #79895 - Kerollmops:slice-group-by, r=m-ou-se
The return of the GroupBy and GroupByMut iterators on slice

According to https://github.com/rust-lang/rfcs/pull/2477#issuecomment-742034372, I am opening this PR again, this time I implemented it in safe Rust only, it is therefore much easier to read and is completely safe.

This PR proposes to add two new methods to the slice, the `group_by` and `group_by_mut`. These two methods provide a way to iterate over non-overlapping sub-slices of a base slice that are separated by the predicate given by the user (e.g. `Partial::eq`, `|a, b| a.abs() < b.abs()`).

```rust
let slice = &[1, 1, 1, 3, 3, 2, 2, 2];

let mut iter = slice.group_by(|a, b| a == b);
assert_eq!(iter.next(), Some(&[1, 1, 1][..]));
assert_eq!(iter.next(), Some(&[3, 3][..]));
assert_eq!(iter.next(), Some(&[2, 2, 2][..]));
assert_eq!(iter.next(), None);
```

[An RFC](https://github.com/rust-lang/rfcs/pull/2477) was open 2 years ago but wasn't necessary.
2020-12-31 12:00:43 +00:00
..
arc.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
binary_heap.rs in-place collect for Vec. Box<[]> and BinaryHeap IntoIter and some adapters 2020-09-03 20:59:03 +02:00
borrow.rs Move various ui const tests to library 2020-09-04 02:35:27 +02:00
boxed.rs review: fix nits and move panic safety tests to the correct place 2020-09-25 23:10:24 +02:00
btree_set_hash.rs Move btree unit test to their native, privileged location 2020-08-14 17:54:09 +02:00
cow_str.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
fmt.rs review: fix nits and move panic safety tests to the correct place 2020-09-25 23:10:24 +02:00
heap.rs Rename AllocRef to Allocator and (de)alloc to (de)allocate 2020-12-04 14:47:15 +01:00
lib.rs Auto merge of #79895 - Kerollmops:slice-group-by, r=m-ou-se 2020-12-31 12:00:43 +00:00
linked_list.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
rc.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
slice.rs Update the slice GroupBy/Mut test 2020-12-10 13:42:31 +01:00
str.rs break formatting so rustfmt is happy 2020-12-02 14:09:36 +01:00
string.rs Added test for issue #78498 2020-10-29 12:25:02 +01:00
vec_deque.rs replace assert! with assert_eq! 2020-12-13 10:21:24 +01:00
vec.rs Fix new 'unnecessary trailing semicolon' warnings 2020-11-26 17:08:36 -05:00