Skip to content

Instantly share code, notes, and snippets.

@justgage
Created October 29, 2015 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justgage/98bc40778a18fef702ca to your computer and use it in GitHub Desktop.
Save justgage/98bc40778a18fef702ca to your computer and use it in GitHub Desktop.
An implementation of rock, paper, scissors that mostly cheats. (part 1)
use std::io;
use std::io::Write;
fn prompt() -> String {
let input = io::stdin();
println!("Welcome to Rock, Paper, and Sinners!");
print!("Please enter rock/paper/sinners:");
io::stdout().flush().ok().expect("flush failed");
let mut guess = String::new();
input.read_line(&mut guess)
.ok()
.expect("Failed to read line");
guess // note the lack of semi-collon
}
fn main() {
println!("Guess the number!");
println!("You guessed: {}", prompt());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment