Open cheako opened 2 years ago
"AND", you can't use ready!
as this is called multiple times in succession. Returning Ready
and then Pending
is a panic.
diff --git a/src/async_bufreader.rs b/src/async_bufreader.rs
index bb5557c..836c6fa 100644
--- a/src/async_bufreader.rs
+++ b/src/async_bufreader.rs
@@ -171,9 +171,16 @@ impl<R: AsyncRead> AsyncBufRead for BufReader<R> {
}
}
- let read = ready!(this.inner.poll_read(cx, this.buffer))?;
- *this.cap += read;
-
+ match this.inner.poll_read(cx, &mut this.buffer[*this.cap..]) {
+ Poll::Pending => {
+ /* This is supposed to let the compiler know pos can never be greater than cap... or something */
+ if *this.pos < *this.cap {
+ } else {
+ return Poll::Pending;
+ }
+ }
+ Poll::Ready(read) => *this.cap += read?,
+ }
Poll::Ready(Ok(&this.buffer[*this.pos..*this.cap]))
}
Line 174
s/this.buffer/this.buffer[*this.cap..]/
.