futures_lite::stream

Function 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);