fix memstream impl

This commit is contained in:
Edward Shen 2021-04-18 17:17:31 -04:00
parent de17c738d2
commit 2650a96d16
Signed by: edward
GPG key ID: 19182661E818369F

4
src/cache/mod.rs vendored
View file

@ -188,13 +188,9 @@ impl Stream for MemStream {
fn poll_next(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let mut new_bytes = Bytes::new();
std::mem::swap(&mut self.0, &mut new_bytes);
if new_bytes.is_empty() {
Poll::Ready(None)
} else {
Poll::Ready(Some(Ok(new_bytes)))
}
}
}
#[cfg(test)]
mod tests {