This is an automated email from the ASF dual-hosted git repository.

msciabarra pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-openwhisk-runtime-rust.git

commit d294fdccb19315fa497308b8f2a8864359603dd0
Author: Bruce Adams <b...@us.ibm.com>
AuthorDate: Thu Mar 7 08:30:03 2019 -0500

    Clarify main loop: lines of input
---
 rust1.32/src/action_loop/src/main.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/rust1.32/src/action_loop/src/main.rs 
b/rust1.32/src/action_loop/src/main.rs
index 9329648..7d874c9 100644
--- a/rust1.32/src/action_loop/src/main.rs
+++ b/rust1.32/src/action_loop/src/main.rs
@@ -6,7 +6,7 @@ use std::{
     collections::HashMap,
     env,
     fs::File,
-    io::{stderr, stdin, stdout, Write},
+    io::{stderr, stdin, stdout, BufRead, Write},
     os::unix::io::FromRawFd,
 };
 
@@ -19,9 +19,9 @@ struct Input {
 
 fn main() {
     let mut fd3 = unsafe { File::from_raw_fd(3) };
-    loop {
-        let mut buffer = String::new();
-        stdin().read_line(&mut buffer).unwrap();
+    let stdin = stdin();
+    for line in stdin.lock().lines() {
+        let buffer: String = line.expect("Error reading line");
         let parsed_input: Result<Input, Error> = serde_json::from_str(&buffer);
         match parsed_input {
             Ok(input) => {

Reply via email to