Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate enum_map;
- use enum_map::{enum_map, EnumMap};
- enum CellStatus{
- Empty,
- Cross,
- Circle,
- }
- enum GameStatus {
- Playing,
- CrossWin,
- CircleWin,
- Draw,
- }
- enum PlayerTurn {
- Cross,
- Circle,
- }
- fn print_board(board: &[CellStatus], celldict: &EnumMap<&CellStatus, &str>){
- for cell in board{
- println!("{}", celldict[cell]);
- }
- }
- fn main() {
- let cell_repr = enum_map! {
- CellStatus::Empty => " _ ".to_string(),
- CellStatus::Cross => " X ".to_string(),
- CellStatus::Circle => " O ".to_string(),
- };
- let mut board = [CellStatus::Empty, CellStatus::Empty, CellStatus::Empty,
- CellStatus::Empty, CellStatus::Empty, CellStatus::Empty,
- CellStatus::Empty, CellStatus::Empty, CellStatus::Empty];
- let mut status = GameStatus::Playing;
- let mut turn = PlayerTurn::Cross;
- print_board(&board, &cell_repr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement