Function futures_lite::stream::once_future

source ·
pub fn once_future<F: Future>(future: F) -> OnceFuture<F>
Expand description

Creates a stream that invokes the given future as its first item, and then produces no more items.

§Example

use futures_lite::{stream, prelude::*};

let mut stream = Box::pin(stream::once_future(async { 1 }));
assert_eq!(stream.next().await, Some(1));
assert_eq!(stream.next().await, None);