feat: Implement size_hint for stream::Filter

Signed-off-by: John Nunley <dev@notgull.net>
This commit is contained in:
John Nunley 2024-01-03 19:17:07 -08:00 committed by GitHub
parent 3b14c82b11
commit abb80b96b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -2307,6 +2307,14 @@ where
}
}
}
fn size_hint(&self) -> (usize, Option<usize>) {
let (_, hi) = self.stream.size_hint();
// If the filter matches all of the elements, it will match the stream's upper bound.
// If the filter matches none of the elements, there will be zero returned values.
(0, hi)
}
}
/// Merges two streams, preferring items from `stream1` whenever both streams are ready.