Last active
November 10, 2016 22:09
-
-
Save 4e1e0603/4944f3761dfa8e34272f464e45809f7c to your computer and use it in GitHub Desktop.
Run the endless loop and quit when the user types ':quit'.
This file contains 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::{BufRead}; | |
fn main() { | |
println!("Type :quit<Enter> to quit this program."); | |
let stdin = std::io::stdin(); | |
loop { | |
let line = stdin.lock().lines().next().unwrap().unwrap(); | |
match line.as_ref() { | |
":quit" => std::process::exit(0), | |
_ => { break } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment