Make default is_end_stream pessimistically return false (#15)

* Make default is_end_stream pessimistically return false

* Fix test to ensure no size hint will default to an ended stream

Signed-off-by: Lucio Franco <luciofranco14@gmail.com>
This commit is contained in:
Sean McArthur
2019-08-20 20:11:39 -07:00
committed by Lucio Franco
parent cfdb1f3a5a
commit f4694c7e82
2 changed files with 2 additions and 7 deletions
+1 -6
View File
@@ -66,12 +66,7 @@ pub trait Body {
/// A return value of `false` **does not** guarantee that a value will be
/// returned from `poll_stream` or `poll_trailers`.
fn is_end_stream(&self) -> bool {
let size_hint = self.size_hint();
size_hint
.upper()
.map(|upper| upper == 0 && upper == size_hint.lower())
.unwrap_or(false)
false
}
/// Returns the bounds on the remaining length of the stream.
+1 -1
View File
@@ -37,7 +37,7 @@ fn is_end_stream_true() {
(Some(123), None, false),
(Some(0), Some(123), false),
(Some(123), Some(123), false),
(Some(0), Some(0), true),
(Some(0), Some(0), false),
];
for &(lower, upper, is_end_stream) in &combos {