Skip to content

Commit 133f9ce

Browse files
taiki-ecramertj
authored andcommitted
Change stream bounds of send_all
1 parent 4fef913 commit 133f9ce

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

futures-util/src/sink/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub trait SinkExt<Item>: Sink<Item> {
223223
&'a mut self,
224224
stream: &'a mut St
225225
) -> SendAll<'a, Self, St>
226-
where &'a mut St: TryStream<Ok = Item, Error = Self::Error> + Unpin,
226+
where St: TryStream<Ok = Item, Error = Self::Error> + Stream + Unpin + ?Sized,
227227
Self: Unpin,
228228
{
229229
SendAll::new(self, stream)

futures-util/src/sink/send_all.rs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::stream::{StreamExt, TryStreamExt, Fuse, IntoStream};
1+
use crate::stream::{StreamExt, TryStreamExt, Fuse};
22
use core::fmt;
33
use core::pin::Pin;
44
use futures_core::future::Future;
5-
use futures_core::stream::TryStream;
5+
use futures_core::stream::{TryStream, Stream};
66
use futures_core::task::{Context, Poll};
77
use futures_sink::Sink;
88

@@ -12,20 +12,18 @@ use futures_sink::Sink;
1212
pub struct SendAll<'a, Si, St>
1313
where
1414
Si: ?Sized,
15-
St: ?Sized,
16-
&'a mut St: TryStream,
15+
St: ?Sized + TryStream,
1716
{
1817
sink: &'a mut Si,
19-
stream: Fuse<IntoStream<&'a mut St>>,
20-
buffered: Option<<&'a mut St as TryStream>::Ok>,
18+
stream: Fuse<&'a mut St>,
19+
buffered: Option<St::Ok>,
2120
}
2221

23-
impl<'a, Si, St> fmt::Debug for SendAll<'a, Si, St>
22+
impl<Si, St> fmt::Debug for SendAll<'_, Si, St>
2423
where
2524
Si: fmt::Debug + ?Sized,
26-
St: fmt::Debug + ?Sized,
27-
&'a mut St: TryStream,
28-
<&'a mut St as TryStream>::Ok: fmt::Debug,
25+
St: fmt::Debug + ?Sized + TryStream,
26+
St::Ok: fmt::Debug,
2927
{
3028
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3129
f.debug_struct("SendAll")
@@ -37,34 +35,32 @@ where
3735
}
3836

3937
// Pinning is never projected to any fields
40-
impl<'a, Si, St> Unpin for SendAll<'a, Si, St>
38+
impl<Si, St> Unpin for SendAll<'_, Si, St>
4139
where
4240
Si: Unpin + ?Sized,
43-
St: ?Sized,
44-
&'a mut St: TryStream + Unpin,
41+
St: TryStream + Unpin + ?Sized,
4542
{}
4643

4744
impl<'a, Si, St, Ok, Error> SendAll<'a, Si, St>
4845
where
4946
Si: Sink<Ok, Error = Error> + Unpin + ?Sized,
50-
St: ?Sized,
51-
&'a mut St: TryStream<Ok = Ok, Error = Error> + Unpin,
47+
St: TryStream<Ok = Ok, Error = Error> + Stream + Unpin + ?Sized,
5248
{
5349
pub(super) fn new(
5450
sink: &'a mut Si,
5551
stream: &'a mut St,
5652
) -> SendAll<'a, Si, St> {
5753
SendAll {
5854
sink,
59-
stream: stream.into_stream().fuse(),
55+
stream: stream.fuse(),
6056
buffered: None,
6157
}
6258
}
6359

6460
fn try_start_send(
6561
&mut self,
6662
cx: &mut Context<'_>,
67-
item: <&'a mut St as TryStream>::Ok,
63+
item: St::Ok,
6864
) -> Poll<Result<(), Si::Error>> {
6965
debug_assert!(self.buffered.is_none());
7066
match Pin::new(&mut self.sink).poll_ready(cx)? {
@@ -79,11 +75,10 @@ where
7975
}
8076
}
8177

82-
impl<'a, Si, St, Ok, Error> Future for SendAll<'a, Si, St>
78+
impl<Si, St, Ok, Error> Future for SendAll<'_, Si, St>
8379
where
8480
Si: Sink<Ok, Error = Error> + Unpin + ?Sized,
85-
St: ?Sized,
86-
&'a mut St: TryStream<Ok = Ok, Error = Error> + Unpin,
81+
St: Stream<Item = Result<Ok, Error>> + Unpin + ?Sized,
8782
{
8883
type Output = Result<(), Error>;
8984

0 commit comments

Comments
 (0)