Commit 12843a5
committed
Add split and split_inclusive
Collect all iterator elements into one of two partitions.
Unlike [`Iterator::partition`], when predicate returns true for the first time,
it collects this element and all rest elements into B.
```rust
use itertools::Itertools;
let nums = vec![0, 1, 2, 3, 4, 5];
let (a, b): (Vec<_>, Vec<_>) = nums.into_iter().split(|n| *n == 3);
assert_eq!(a, [0, 1, 2]);
assert_eq!(b, [3, 4, 5]);
```
---
Collect all iterator elements into one of two partitions.
Unlike [`Itertools::split`], when predicate returns true, the element is collected into A
```rust
use itertools::Itertools;
let nums = vec![0, 1, 2, 3, 4, 5];
let (a, b): (Vec<_>, Vec<_>) = nums.into_iter().split_inclusive(|n| *n == 3);
assert_eq!(a, [0, 1, 2, 3]);
assert_eq!(b, [4, 5]);
```1 parent 61c5a7a commit 12843a5
1 file changed
+71
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3701 | 3701 | | |
3702 | 3702 | | |
3703 | 3703 | | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
| 3735 | + | |
| 3736 | + | |
| 3737 | + | |
| 3738 | + | |
| 3739 | + | |
| 3740 | + | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
| 3744 | + | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
| 3760 | + | |
| 3761 | + | |
| 3762 | + | |
| 3763 | + | |
| 3764 | + | |
| 3765 | + | |
| 3766 | + | |
| 3767 | + | |
| 3768 | + | |
| 3769 | + | |
| 3770 | + | |
| 3771 | + | |
| 3772 | + | |
| 3773 | + | |
| 3774 | + | |
3704 | 3775 | | |
3705 | 3776 | | |
3706 | 3777 | | |
| |||
0 commit comments