Skip to content

Commit 4a62bb6

Browse files
ebkalderoncramertj
authored andcommitted
Update Forward docs, remove Unpin sink requirement
1 parent 9685d93 commit 4a62bb6

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

futures-util/src/stream/forward.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,10 @@ use pin_utils::{unsafe_pinned, unsafe_unpinned};
99
const INVALID_POLL: &str = "polled `Forward` after completion";
1010

1111
/// 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.
1913
#[derive(Debug)]
2014
#[must_use = "steams do nothing unless polled"]
21-
pub struct Forward<St: Stream, Si: Sink + Unpin> {
15+
pub struct Forward<St: Stream, Si: Sink> {
2216
sink: Option<Si>,
2317
stream: Fuse<St>,
2418
buffered_item: Option<Si::SinkItem>,
@@ -28,7 +22,7 @@ impl<St: Stream + Unpin, Si: Sink + Unpin> Unpin for Forward<St, Si> {}
2822

2923
impl<St, Si> Forward<St, Si>
3024
where
31-
Si: Sink + Unpin,
25+
Si: Sink,
3226
St: Stream<Item = Result<Si::SinkItem, Si::SinkError>>,
3327
{
3428
unsafe_pinned!(sink: Option<Si>);
@@ -68,7 +62,7 @@ impl<St: Stream, Si: Sink + Unpin> FusedFuture for Forward<St, Si> {
6862

6963
impl<St, Si> Future for Forward<St, Si>
7064
where
71-
Si: Sink + Unpin,
65+
Si: Sink,
7266
St: Stream<Item = Result<Si::SinkItem, Si::SinkError>>,
7367
{
7468
type Output = Result<(), Si::SinkError>;
@@ -91,7 +85,7 @@ where
9185
Poll::Ready(None) => {
9286
try_ready!(self.as_mut().sink().as_pin_mut().expect(INVALID_POLL)
9387
.poll_close(waker));
94-
let _ = self.as_mut().sink().take().unwrap();
88+
let _ = self.as_mut().sink().as_pin_mut().take().unwrap();
9589
return Poll::Ready(Ok(()))
9690
}
9791
Poll::Pending => {

0 commit comments

Comments
 (0)