Skip to content

Commit b3fe350

Browse files
committed
Update doc for .flatten()
1 parent 4b7bf7e commit b3fe350

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -909,17 +909,18 @@ pub trait Itertools : Iterator {
909909

910910
/// Unravel a nested iterator.
911911
///
912-
/// This is a shortcut for `it.flat_map(|x| x)`.
912+
/// This is more or less equivalent to `.flat_map` with an identity
913+
/// function.
913914
///
914915
/// ```
915916
/// use itertools::Itertools;
916917
///
917918
/// let data = vec![vec![1, 2, 3], vec![4, 5, 6]];
918-
/// let flattened = data.into_iter().flatten();
919+
/// let flattened = data.iter().flatten();
919920
///
920-
/// itertools::assert_equal(flattened, vec![1, 2, 3, 4, 5, 6]);
921+
/// itertools::assert_equal(flattened, &[1, 2, 3, 4, 5, 6]);
921922
/// ```
922-
fn flatten(self) -> Flatten<Self, <<Self as Iterator>::Item as IntoIterator>::IntoIter>
923+
fn flatten(self) -> Flatten<Self, <Self::Item as IntoIterator>::IntoIter>
923924
where Self: Sized,
924925
Self::Item: IntoIterator
925926
{

0 commit comments

Comments
 (0)