doc: Add stream unzip doc

new-scheduler
k-nasa 5 years ago
parent 603b3c5085
commit 91ee4c7b9f

@ -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>]

Loading…
Cancel
Save