Skip to content

Commit 96b7d07

Browse files
committed
Mention nested unzip in its documentation
1 parent c8f5d6d commit 96b7d07

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/core/src/iter/traits/iterator.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2811,6 +2811,14 @@ pub trait Iterator {
28112811
///
28122812
/// assert_eq!(left, [1, 3]);
28132813
/// assert_eq!(right, [2, 4]);
2814+
///
2815+
/// // you can also unzip multiple nested tuples at once
2816+
/// let a = [(1, (2, 3)), (4, (5, 6))];
2817+
///
2818+
/// let (x, (y, z)): (Vec<_>, (Vec<_>, Vec<_>)) = a.iter().cloned().unzip();
2819+
/// assert_eq!(x, [1, 4]);
2820+
/// assert_eq!(y, [2, 5]);
2821+
/// assert_eq!(z, [3, 6]);
28142822
/// ```
28152823
#[stable(feature = "rust1", since = "1.0.0")]
28162824
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)

0 commit comments

Comments
 (0)