Function tokio::stream::once [−][src]
pub fn once<T>(value: T) -> Once<T>
Creates a stream that emits an element exactly once.
The returned stream is immediately ready and emits the provided value once.
Examples
use tokio::stream::{self, StreamExt}; #[tokio::main] async fn main() { // one is the loneliest number let mut one = stream::once(1); assert_eq!(Some(1), one.next().await); // just one, that's all we get assert_eq!(None, one.next().await); }