Skip to content

Commit

Permalink
Merge #459
Browse files Browse the repository at this point in the history
459: Clarify documentation for `merge_by` r=jswrenn a=phimuemue

I think simply stating the elements is easier than going through `map`.

Co-authored-by: philipp <descpl@yahoo.de>
  • Loading branch information
bors[bot] and phimuemue committed Jul 13, 2020
2 parents 589b784 + 1329323 commit b00d7c6
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/lib.rs
Expand Up @@ -876,17 +876,13 @@ pub trait Itertools : Iterator {
/// use itertools::Itertools;
/// use itertools::EitherOrBoth::{Left, Right, Both};
///
/// let ki = (0..10).step(3);
/// let ku = (0..10).step(5);
/// let ki_ku = ki.merge_join_by(ku, |i, j| i.cmp(j)).map(|either| {
/// match either {
/// Left(_) => "Ki",
/// Right(_) => "Ku",
/// Both(_, _) => "KiKu"
/// }
/// });
/// let multiples_of_2 = (0..10).step(2);
/// let multiples_of_3 = (0..10).step(3);
///
/// itertools::assert_equal(ki_ku, vec!["KiKu", "Ki", "Ku", "Ki", "Ki"]);
/// itertools::assert_equal(
/// multiples_of_2.merge_join_by(multiples_of_3, |i, j| i.cmp(j)),
/// vec![Both(0, 0), Left(2), Right(3), Left(4), Both(6, 6), Left(8), Right(9)]
/// );
/// ```
#[inline]
fn merge_join_by<J, F>(self, other: J, cmp_fn: F) -> MergeJoinBy<Self, J::IntoIter, F>
Expand Down

0 comments on commit b00d7c6

Please sign in to comment.