diff options
| author | Sebastian Widua <seppel3210@gmail.com> | 2021-06-14 17:01:40 +0200 |
|---|---|---|
| committer | Sebastian Widua <seppel3210@gmail.com> | 2021-06-14 17:01:40 +0200 |
| commit | 96b7d07a477fc118b045e4ed49086dcf6975b962 (patch) | |
| tree | 54538c0e0f7ae2c13555e1f580d89ac059a42b1e | |
| parent | c8f5d6d80d397334eb613cf3e414028af68f3f02 (diff) | |
| download | rust-96b7d07a477fc118b045e4ed49086dcf6975b962.tar.gz rust-96b7d07a477fc118b045e4ed49086dcf6975b962.zip | |
Mention nested unzip in its documentation
| -rw-r--r-- | library/core/src/iter/traits/iterator.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index a7e914526f4..97d6d470b36 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -2811,6 +2811,14 @@ pub trait Iterator { /// /// assert_eq!(left, [1, 3]); /// assert_eq!(right, [2, 4]); + /// + /// // you can also unzip multiple nested tuples at once + /// let a = [(1, (2, 3)), (4, (5, 6))]; + /// + /// let (x, (y, z)): (Vec<_>, (Vec<_>, Vec<_>)) = a.iter().cloned().unzip(); + /// assert_eq!(x, [1, 4]); + /// assert_eq!(y, [2, 5]); + /// assert_eq!(z, [3, 6]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) |
