Skip to content

Conversation

@maradini77
Copy link

Description

Fix panic in chat example when stdin reaches EOF or encounters an error.

Previously, the tokio::select! macro used pattern matching (Ok(Some(line))) which would panic if stdin.next_line() returned Ok(None) (EOF) or Err(_). This made the example crash when stdin was closed, making it unsuitable for use in scripts or automated scenarios.

The fix explicitly handles all possible outcomes of stdin.next_line():

  • Ok(Some(line)) - process the line as before
  • Ok(None) - gracefully exit when EOF is reached
  • Err(e) - return the error instead of panicking

This ensures the example can be safely used in pipelines and automated environments.

@elenaf9 elenaf9 closed this Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants