From: LukeMathWalker <20745048+LukeMathWalker@users.noreply.github.com> Date: Thu, 16 May 2024 11:17:59 +0000 (+0200) Subject: Add StreamExt::merge X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=95bddb12ca2f9204bdb335cea865ec81342bb6dd;p=rust_exercises.git Add StreamExt::merge --- diff --git a/book/src/08_futures/07_cancellation.md b/book/src/08_futures/07_cancellation.md index 557aa72..70c1954 100644 --- a/book/src/08_futures/07_cancellation.md +++ b/book/src/08_futures/07_cancellation.md @@ -102,6 +102,8 @@ async fn run() { - Be extremely careful when using `tokio`'s `select!` macro to "race" two different futures. Retrying the same task in a loop is dangerous unless you can ensure **cancellation safety**. - Check out [`select!`'s documentation](https://docs.rs/tokio/macro.select.html) for more details. + Check out [`select!`'s documentation](https://docs.rs/tokio/macro.select.html) for more details. + If you need to interleave two asynchronous streams of data (e.g. a socket and a channel), prefer using + [`StreamExt::merge`](https://docs.rs/tokio-stream/latest/tokio_stream/trait.StreamExt.html#method.merge) instead. - Rather than "abrupt" cancellation, it can be preferable to rely on [`CancellationToken`](https://docs.rs/tokio-util/latest/tokio_util/sync/struct.CancellationToken.html). \ No newline at end of file