Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3b03af8

Browse files
docs: add comment explaining non-standard iterator semantics
1 parent 5a870ff commit 3b03af8

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/os/shared.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ pub struct TerminalEvents;
4444

4545
impl Iterator for TerminalEvents {
4646
type Item = Event;
47+
/// Returns the next terminal event, or `None` if no event is available
48+
/// within the poll timeout.
49+
///
50+
/// Note: `None` here means "no event right now", not "iteration complete".
51+
/// The consumer should use `while running` instead of `for evt in ...`.
4752
fn next(&mut self) -> Option<Event> {
48-
// Poll with timeout instead of blocking read to allow
49-
// the caller to check for shutdown signals
5053
match poll(POLL_TIMEOUT) {
5154
Ok(true) => read().ok(),
5255
Ok(false) | Err(_) => None,

0 commit comments

Comments
 (0)