]>
git.proxmox.com Git - rustc.git/blob - vendor/futures-util/src/stream/try_stream/try_concat.rs
2 use futures_core
::future
::Future
;
3 use futures_core
::ready
;
4 use futures_core
::stream
::TryStream
;
5 use futures_core
::task
::{Context, Poll}
;
6 use pin_project_lite
::pin_project
;
9 /// Future for the [`try_concat`](super::TryStreamExt::try_concat) method.
11 #[must_use = "futures do nothing unless you `.await` or poll them"]
12 pub struct TryConcat
<St
: TryStream
> {
15 accum
: Option
<St
::Ok
>,
19 impl<St
> TryConcat
<St
>
22 St
::Ok
: Extend
<<St
::Ok
as IntoIterator
>::Item
> + IntoIterator
+ Default
,
24 pub(super) fn new(stream
: St
) -> Self {
25 Self { stream, accum: None }
29 impl<St
> Future
for TryConcat
<St
>
32 St
::Ok
: Extend
<<St
::Ok
as IntoIterator
>::Item
> + IntoIterator
+ Default
,
34 type Output
= Result
<St
::Ok
, St
::Error
>;
36 fn poll(self: Pin
<&mut Self>, cx
: &mut Context
<'_
>) -> Poll
<Self::Output
> {
37 let mut this
= self.project();
40 if let Some(x
) = ready
!(this
.stream
.as_mut().try_poll_next(cx
)?
) {
41 if let Some(a
) = this
.accum
{
47 break this
.accum
.take().unwrap_or_default();