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:
Rachit2323
2026-05-01 14:09:28 +02:00
committed by GitHub
parent 26dee92b53
commit 5030b3005e
11 changed files with 297 additions and 0 deletions
+11
View File
@@ -3,6 +3,7 @@ use crate::Stream;
use core::fmt;
use core::pin::Pin;
use core::task::{Context, Poll};
use futures_core::FusedStream;
use pin_project_lite::pin_project;
pin_project! {
@@ -77,3 +78,13 @@ where
(0, upper)
}
}
impl<St, F> FusedStream for TakeWhile<St, F>
where
St: Stream,
F: FnMut(&St::Item) -> bool,
{
fn is_terminated(&self) -> bool {
self.done
}
}