Created
October 29, 2015 23:38
-
-
Save justgage/98bc40778a18fef702ca to your computer and use it in GitHub Desktop.
An implementation of rock, paper, scissors that mostly cheats. (part 1)
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; | |
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