futures::stream

Function once

Source
pub fn once<Fut>(future: Fut) -> Once<Fut>
where Fut: Future,
Expand description

Creates a stream of a single element.

use futures::stream::{self, StreamExt};

let stream = stream::once(async { 17 });
let collected = stream.collect::<Vec<i32>>().await;
assert_eq!(collected, vec![17]);