Correctly override size_hint and is_end_stream for Empty (#42)

I noticed this while working on
https://github.com/hyperium/tonic/pull/622 as it broke some interop
tests.
This commit is contained in:
David Pedersen
2021-05-08 15:59:42 +02:00
committed by GitHub
parent f7b0f7d6c4
commit e6bf1bff18
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
# Unreleased
Nothing.
- Correctly override `Body::size_hint` and `Body::is_end_stream` for `Empty`.
# 0.4.1 (March 18, 2021)
+9 -1
View File
@@ -1,4 +1,4 @@
use super::Body;
use super::{Body, SizeHint};
use bytes::Buf;
use http::HeaderMap;
use std::{
@@ -40,6 +40,14 @@ impl<D: Buf> Body for Empty<D> {
) -> Poll<Result<Option<HeaderMap>, Self::Error>> {
Poll::Ready(Ok(None))
}
fn is_end_stream(&self) -> bool {
true
}
fn size_hint(&self) -> SizeHint {
SizeHint::with_exact(0)
}
}
impl<D> fmt::Debug for Empty<D> {