Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify documentation for group_by #375

Merged
merged 1 commit into from
Dec 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Clarify documentation for group_by
phimuemue committed Oct 15, 2019
commit 97c6265e15b2c712b336de901b8f483935d24460
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -505,10 +505,11 @@ pub trait Itertools : Iterator {
///
/// // Note: The `&` is significant here, `GroupBy` is iterable
/// // only by reference. You can also call `.into_iter()` explicitly.
/// let mut data_grouped = Vec::new();
/// for (key, group) in &data.into_iter().group_by(|elt| *elt >= 0) {
/// // Check that the sum of each group is +/- 4.
/// assert_eq!(4, group.sum::<i32>().abs());
/// data_grouped.push((key, group.collect()));
/// }
/// assert_eq!(data_grouped, vec![(true, vec![1, 3]), (false, vec![-2, -2]), (true, vec![1, 0, 1, 2])]);
/// ```
#[cfg(feature = "use_std")]
fn group_by<K, F>(self, key: F) -> GroupBy<K, Self, F>