Sha256: bb4c585281a00de64e36ea7a3c2f8d7ce5c21d296698f85ec817f04c742fd251

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

//! The `stream_select` macro.

#[allow(unreachable_pub)]
#[doc(hidden)]
pub use futures_macro::stream_select_internal;

#[allow(clippy::too_long_first_doc_paragraph)]
/// Combines several streams, all producing the same `Item` type, into one stream.
/// This is similar to `select_all` but does not require the streams to all be the same type.
/// It also keeps the streams inline, and does not require `Box<dyn Stream>`s to be allocated.
/// Streams passed to this macro must be `Unpin`.
///
/// If multiple streams are ready, one will be pseudo randomly selected at runtime.
///
/// # Examples
///
/// ```
/// # futures::executor::block_on(async {
/// use futures::{stream, StreamExt, stream_select};
/// let endless_ints = |i| stream::iter(vec![i].into_iter().cycle()).fuse();
///
/// let mut endless_numbers = stream_select!(endless_ints(1i32), endless_ints(2), endless_ints(3));
/// match endless_numbers.next().await {
///     Some(1) => println!("Got a 1"),
///     Some(2) => println!("Got a 2"),
///     Some(3) => println!("Got a 3"),
///     _ => unreachable!(),
/// }
/// # });
/// ```
#[macro_export]
macro_rules! stream_select {
    ($($tokens:tt)*) => {{
        use $crate::__private as __futures_crate;
        $crate::stream_select_internal! {
            $( $tokens )*
        }
    }}
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/futures-util-0.3.31/src/async_await/stream_select_mod.rs
wasmtime-28.0.0 ./ext/cargo-vendor/futures-util-0.3.31/src/async_await/stream_select_mod.rs
wasmtime-27.0.0 ./ext/cargo-vendor/futures-util-0.3.31/src/async_await/stream_select_mod.rs
wasmtime-26.0.0 ./ext/cargo-vendor/futures-util-0.3.31/src/async_await/stream_select_mod.rs