mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +02:00
tokio-stream: implement FusedStream for various stream adaptors (#8096)
`MapWhile` is intentionally excluded because its current implementation does not track when the closure returns `None` early, making a correct `is_terminated()` impossible without a separate semantic change.
This commit is contained in:
@@ -3,6 +3,7 @@ use crate::Stream;
|
||||
use core::fmt;
|
||||
use core::pin::Pin;
|
||||
use core::task::{ready, Context, Poll};
|
||||
use futures_core::FusedStream;
|
||||
use pin_project_lite::pin_project;
|
||||
|
||||
pin_project! {
|
||||
@@ -71,3 +72,13 @@ where
|
||||
(lower, upper)
|
||||
}
|
||||
}
|
||||
|
||||
impl<St, F> FusedStream for SkipWhile<St, F>
|
||||
where
|
||||
St: FusedStream,
|
||||
F: FnMut(&St::Item) -> bool,
|
||||
{
|
||||
fn is_terminated(&self) -> bool {
|
||||
self.stream.is_terminated()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user