Skip to content

Commit 1329323

Browse files
committed
Clarify documentation for merge_by
1 parent e3ea516 commit 1329323

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -876,17 +876,13 @@ pub trait Itertools : Iterator {
876876
/// use itertools::Itertools;
877877
/// use itertools::EitherOrBoth::{Left, Right, Both};
878878
///
879-
/// let ki = (0..10).step(3);
880-
/// let ku = (0..10).step(5);
881-
/// let ki_ku = ki.merge_join_by(ku, |i, j| i.cmp(j)).map(|either| {
882-
/// match either {
883-
/// Left(_) => "Ki",
884-
/// Right(_) => "Ku",
885-
/// Both(_, _) => "KiKu"
886-
/// }
887-
/// });
879+
/// let multiples_of_2 = (0..10).step(2);
880+
/// let multiples_of_3 = (0..10).step(3);
888881
///
889-
/// itertools::assert_equal(ki_ku, vec!["KiKu", "Ki", "Ku", "Ki", "Ki"]);
882+
/// itertools::assert_equal(
883+
/// multiples_of_2.merge_join_by(multiples_of_3, |i, j| i.cmp(j)),
884+
/// vec![Both(0, 0), Left(2), Right(3), Left(4), Both(6, 6), Left(8), Right(9)]
885+
/// );
890886
/// ```
891887
#[inline]
892888
fn merge_join_by<J, F>(self, other: J, cmp_fn: F) -> MergeJoinBy<Self, J::IntoIter, F>

0 commit comments

Comments
 (0)