diff --git a/tokio/src/time/interval.rs b/tokio/src/time/interval.rs index 090e2d1f05a..661a9404aa7 100644 --- a/tokio/src/time/interval.rs +++ b/tokio/src/time/interval.rs @@ -129,11 +129,19 @@ impl Interval { } } -#[cfg(feature = "stream")] -impl crate::stream::Stream for Interval { - type Item = Instant; +cfg_stream! { + impl futures_core::FusedStream for Interval { + fn is_terminated(&self) -> bool { + // NB: intervals never terminate. + false + } + } + + impl crate::stream::Stream for Interval { + type Item = Instant; - fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - Poll::Ready(Some(ready!(self.poll_tick(cx)))) + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + Poll::Ready(Some(ready!(self.poll_tick(cx)))) + } } }