debounced

Function debounced 

Source
pub fn debounced<S>(stream: S, delay: Duration) -> Debounced<S>
where S: Stream + Unpin,
Expand description

Returns a new stream that delays its items for a given duration and only yields the most recent item afterwards.

use debounced::debounced;

let (mut sender, receiver) = futures_channel::mpsc::channel(1024);
let mut debounced = debounced(receiver, Duration::from_secs(1));
sender.send(21).await;
sender.send(42).await;
assert_eq!(debounced.next().await, Some(42));
assert_eq!(start.elapsed().as_secs(), 1);
std::mem::drop(sender);
assert_eq!(debounced.next().await, None);