[][src]Function num_stream::num_stream

pub fn num_stream(initial: u64, increment: u64, period: Duration) -> NumStream

Creates new NumStream that yields values at an interval of period that continuously increment by increment where the first value yielded is initial.

A NumStream will yield values indefinitely. At any time, the NumStream value can be dropped, canceling the stream.


This function panics if period is zero.


use futures::stream::StreamExt;
use num_stream::num_stream;
use std::time::Duration;
use tokio;

async fn main() {
    let mut nums = num_stream(0, 3, Duration::from_millis(500));
    loop {
        println!("Got: {:?}", nums.next().await);