Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly override size_hint and is_end_stream for Empty #42

Merged
merged 1 commit into from
May 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Unreleased

Nothing.
- Correctly override `Body::size_hint` and `Body::is_end_stream` for `Empty`.

# 0.4.1 (March 18, 2021)

Expand Down
10 changes: 9 additions & 1 deletion src/empty.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::Body;
use super::{Body, SizeHint};
use bytes::Buf;
use http::HeaderMap;
use std::{
Expand Down Expand Up @@ -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> {
Expand Down