Implement FusedStream and FusedFuture for Interval and Delay (#1476)

This commit is contained in:
John-John Tedro
2019-08-19 10:21:34 -04:00
committed by Lucio Franco
parent 68d5fcb8d1
commit 34a9dc2d76
2 changed files with 14 additions and 0 deletions
+7
View File
@@ -91,6 +91,13 @@ impl Delay {
}
}
#[cfg(feature = "async-traits")]
impl futures_core::FusedFuture for Delay {
fn is_terminated(&self) -> bool {
self.is_elapsed()
}
}
impl Future for Delay {
type Output = ();
+7
View File
@@ -100,6 +100,13 @@ impl Interval {
}
}
#[cfg(feature = "async-traits")]
impl futures_core::FusedStream for Interval {
fn is_terminated(&self) -> bool {
false
}
}
#[cfg(feature = "async-traits")]
impl futures_core::Stream for Interval {
type Item = Instant;