2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-03-04 17:19:41 +00:00

doc: Add stream unzip doc

This commit is contained in:
k-nasa 2019-11-16 01:16:48 +09:00
parent 603b3c5085
commit 91ee4c7b9f

View file

@ -1719,6 +1719,33 @@ extension_trait! {
Zip::new(self, other)
}
#[doc = r#"
Converts an stream of pairs into a pair of containers.
unzip() consumes an entire stream of pairs, producing two collections: one from the left elements of the pairs, and one from the right elements.
This function is, in some sense, the opposite of [`zip`].
[`zip`]: trait.Stream.html#method.zip
# Example
```
# fn main() { async_std::task::block_on(async {
#
use async_std::prelude::*;
use async_std::stream;
let s = stream::from_iter(vec![(1,2), (3,4)]);
let (left, right): (Vec<_>, Vec<_>) = s.unzip().await;
assert_eq!(left, [1, 3]);
assert_eq!(right, [2, 4]);
#
# }) }
```
"#]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn unzip<A, B, FromA, FromB>(self) -> impl Future<Output = (FromA, FromB)> [UnzipFuture<Self, FromA, FromB>]