Skip to content

Commit

Permalink
feat: Implement size_hint for stream::Filter
Browse files Browse the repository at this point in the history
Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull authored Jan 4, 2024
1 parent 3b14c82 commit abb80b9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit abb80b9

Please sign in to comment.