Last active
December 28, 2016 06:39
-
-
Save ryochack/77d80c7718e2c310f7aee4915208cb9e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 標準入力を受け取って標準出力に吐き出す | |
| use std::io::{self, Read, Write}; | |
| fn main() { | |
| const N: usize = 8; | |
| let mut buf = [0u8; N]; | |
| loop { | |
| match io::stdin().read(&mut buf) { | |
| Ok(s) => { | |
| if s == 0 { | |
| break; | |
| } | |
| match buf[0] { | |
| b'.' => break, | |
| _ => { | |
| print!(">"); | |
| let _ = io::stdout().write(&buf[0..s]); | |
| } | |
| } | |
| } | |
| Err(e) => { | |
| println!("error: {}", e); | |
| break; | |
| } | |
| }; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment