Skip to content

Instantly share code, notes, and snippets.

@voldyman
Last active May 19, 2016 18:32
Show Gist options
  • Save voldyman/9adc9b5c817b5a5bf3535c6ae2ef682f to your computer and use it in GitHub Desktop.
Save voldyman/9adc9b5c817b5a5bf3535c6ae2ef682f to your computer and use it in GitHub Desktop.
#[derive(Copy, Clone)]
enum Cell {
Empty,
Cross,
Zero
}
fn print_cell(cell: Cell) {
match cell {
Cell::Empty => println!("empty"),
Cell::Cross => println!("cross"),
Cell::Zero => println!("zero")
}
}
fn main() {
let cells: [Cell; 9] = [Cell::Empty; 9];
for (i, cells) in cells.chunks(3).enumerate() {
for (j, cell) in cells.iter().enumerate() {
print!("{},{}: ", i, j);
print_cell(*cell);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment