rust/library/core/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
..
fmt
hash
num
alloc.rs
any.rs
array.rs
ascii.rs
atomic.rs
bool.rs
cell.rs
char.rs
clone.rs
cmp.rs
const_ptr.rs
intrinsics.rs
iter.rs Add Iterator::intersperse 2020-12-30 12:07:19 -08:00
lazy.rs
lib.rs Auto merge of #79895 - Kerollmops:slice-group-by, r=m-ou-se 2020-12-31 12:00:43 +00:00
macros.rs
manually_drop.rs
mem.rs Auto merge of #80511 - Mark-Simulacrum:bump-stage0, r=pietroalbini 2020-12-30 18:32:31 +00:00
nonzero.rs
ops.rs
option.rs
pattern.rs
pin.rs
ptr.rs
result.rs
slice.rs
str_lossy.rs
str.rs
task.rs
time.rs
tuple.rs
unicode.rs