Last active
August 29, 2015 14:01
-
-
Save schmee/bbab7b8ab00eed00e611 to your computer and use it in GitHub Desktop.
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
fn make_human_move1(game: TicTacToe) -> TicTacToe { | |
let mut move = parse_move_from_stdin(); | |
let new_game = game.make_move_from_input(move); | |
loop { | |
match new_game { | |
Some(g) => return g, | |
None => { | |
println!("Bad input / invalid move, try again:"); | |
move = parse_move_from_stdin(); | |
let new_game = game.make_move_from_input(move); | |
} | |
} | |
} | |
} | |
fn make_human_move2(game: TicTacToe) -> TicTacToe { | |
let mut move = parse_move_from_stdin(); | |
let mut new_game = game.make_move_from_input(move); | |
loop { | |
match new_game { | |
Some(g) => return g, | |
None => { | |
println!("Bad input / invalid move, try again:"); | |
move = parse_move_from_stdin(); | |
new_game = game.make_move_from_input(move); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment