time: impl Stream for DelayQueue (#1975)

This commit is contained in:
Ruben De Smet 2019-12-18 06:01:29 +01:00 committed by Carl Lerche
parent 41d15ea212
commit 17e424112d

View File

@ -730,6 +730,17 @@ impl<T> Default for DelayQueue<T> {
}
}
#[cfg(feature = "stream")]
impl<T> futures_core::Stream for DelayQueue<T> {
// DelayQueue seems much more specific, where a user may care that it
// has reached capacity, so return those errors instead of panicking.
type Item = Result<Expired<T>, Error>;
fn poll_next(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Option<Self::Item>> {
DelayQueue::poll_expired(self.get_mut(), cx)
}
}
impl<T> wheel::Stack for Stack<T> {
type Owned = usize;
type Borrowed = usize;