diff --git a/src/main.rs b/src/main.rs index b2bcba8..07d7277 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,12 +32,12 @@ struct Forward { impl Stream for Forward { type Item = smol::io::Result>; - fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - let mut this = self.project(); + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + let mut this = self.as_mut().project(); let mut buf = [0; 65536]; let read = ready!(this.stream.as_mut().poll_read(cx, &mut buf))?; if read == 0 { - ready!(this.stream.poll_close(cx))?; + ready!(self.poll_close(cx))?; Poll::Ready(None) } else { Poll::Ready(Some(Ok(buf[..read].into()))) @@ -75,7 +75,8 @@ impl Sink> for Forward { self.project().stream.poll_flush(cx) } - fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + ready!(self.as_mut().poll_flush(cx))?; self.project().stream.poll_close(cx) } }