@@ -9,16 +9,10 @@ use pin_utils::{unsafe_pinned, unsafe_unpinned};
9
9
const INVALID_POLL : & str = "polled `Forward` after completion" ;
10
10
11
11
/// Future for the `Stream::forward` combinator, which sends a stream of values
12
- /// to a sink and then flushes the sink.
13
- ///
14
- /// Note: this is only usable with `Unpin` sinks, so `Sink`s that aren't `Unpin`
15
- /// will need to be pinned in order to be used with this combinator.
16
- //
17
- // This limitation is necessary in order to return the sink after the forwarding
18
- // has completed so that it can be used again.
12
+ /// to a sink and then flushes and closes the sink.
19
13
#[ derive( Debug ) ]
20
14
#[ must_use = "steams do nothing unless polled" ]
21
- pub struct Forward < St : Stream , Si : Sink + Unpin > {
15
+ pub struct Forward < St : Stream , Si : Sink > {
22
16
sink : Option < Si > ,
23
17
stream : Fuse < St > ,
24
18
buffered_item : Option < Si :: SinkItem > ,
@@ -28,7 +22,7 @@ impl<St: Stream + Unpin, Si: Sink + Unpin> Unpin for Forward<St, Si> {}
28
22
29
23
impl < St , Si > Forward < St , Si >
30
24
where
31
- Si : Sink + Unpin ,
25
+ Si : Sink ,
32
26
St : Stream < Item = Result < Si :: SinkItem , Si :: SinkError > > ,
33
27
{
34
28
unsafe_pinned ! ( sink: Option <Si >) ;
@@ -68,7 +62,7 @@ impl<St: Stream, Si: Sink + Unpin> FusedFuture for Forward<St, Si> {
68
62
69
63
impl < St , Si > Future for Forward < St , Si >
70
64
where
71
- Si : Sink + Unpin ,
65
+ Si : Sink ,
72
66
St : Stream < Item = Result < Si :: SinkItem , Si :: SinkError > > ,
73
67
{
74
68
type Output = Result < ( ) , Si :: SinkError > ;
91
85
Poll :: Ready ( None ) => {
92
86
try_ready ! ( self . as_mut( ) . sink( ) . as_pin_mut( ) . expect( INVALID_POLL )
93
87
. poll_close( waker) ) ;
94
- let _ = self . as_mut ( ) . sink ( ) . take ( ) . unwrap ( ) ;
88
+ let _ = self . as_mut ( ) . sink ( ) . as_pin_mut ( ) . take ( ) . unwrap ( ) ;
95
89
return Poll :: Ready ( Ok ( ( ) ) )
96
90
}
97
91
Poll :: Pending => {
0 commit comments