Skip to content

Commit b00d7c6

Browse files
bors[bot]phimuemue
andauthored
Merge #459
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 <[email protected]>
2 parents 589b784 + 1329323 commit b00d7c6

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)