Skip to content

Commit d294fdc

Browse files
author
Bruce Adams
committed
Clarify main loop: lines of input
1 parent 6617982 commit d294fdc

File tree

1 file changed

+4
-4
lines changed
  • rust1.32/src/action_loop/src

1 file changed

+4
-4
lines changed

rust1.32/src/action_loop/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
collections::HashMap,
77
env,
88
fs::File,
9-
io::{stderr, stdin, stdout, Write},
9+
io::{stderr, stdin, stdout, BufRead, Write},
1010
os::unix::io::FromRawFd,
1111
};
1212

@@ -19,9 +19,9 @@ struct Input {
1919

2020
fn main() {
2121
let mut fd3 = unsafe { File::from_raw_fd(3) };
22-
loop {
23-
let mut buffer = String::new();
24-
stdin().read_line(&mut buffer).unwrap();
22+
let stdin = stdin();
23+
for line in stdin.lock().lines() {
24+
let buffer: String = line.expect("Error reading line");
2525
let parsed_input: Result<Input, Error> = serde_json::from_str(&buffer);
2626
match parsed_input {
2727
Ok(input) => {

0 commit comments

Comments
 (0)