Skip to content

Instantly share code, notes, and snippets.

@4e1e0603
Last active November 10, 2016 22:09
Show Gist options
  • Save 4e1e0603/4944f3761dfa8e34272f464e45809f7c to your computer and use it in GitHub Desktop.
Save 4e1e0603/4944f3761dfa8e34272f464e45809f7c to your computer and use it in GitHub Desktop.
Run the endless loop and quit when the user types ':quit'.
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