Heh, found a neat pattern today. To add an item to a stream after it's finished (useful when joining streams) you can use `.chain`: let s = s.chain(stream::once(1u8)); If you then run this through stream::join, you can ensure that each individual stream emits a msg on close
-
Show this thread
-
We're probably going to rename `stream::join` to `stream::Stream::merge` by the way. Filed the PR for it earlier. It's now more similar to `Stream::{chain,zip,unzip}`!https://github.com/async-rs/async-std/pull/321 …
1 reply 0 retweets 3 likesShow this thread
let a = stream::repeat(1u8).take(2); let a = a.chain(stream::once(2u8)); let b = stream::repeat(3u8).take(2); let b = b.chain(stream::once(4u8)); let s = a.merge(b); s.for_each(|num| dbg!(num)).await; // => 1, 1, 2, 3, 3, 4
3:08 PM - 13 Oct 2019
from Berlin, Germany
0 replies
1 retweet
10 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.