Skip to content
Snippets Groups Projects
Commit e0fc4238 authored by Michael Hauspie's avatar Michael Hauspie
Browse files

Simple display and rustfmt

parent dbb74bcc
No related branches found
No related tags found
No related merge requests found
struct TicTacToe { struct TicTacToe {
board: [char; 9] board: [char; 9],
} }
fn display(board: TicTacToe) { fn display(board: TicTacToe) {
for row in 0..3 {
println!(" {} | {} | {}", println!(
board.board[0], " {} | {} | {}",
board.board[1], board.board[row * 3],
board.board[2]); board.board[row * 3 + 1],
println!("---+---+--"); board.board[row * 3 + 2]
println!(" {} | {} | {}", );
board.board[3], }
board.board[4],
board.board[5]);
println!("---+---+---");
println!(" {} | {} | {}",
board.board[6],
board.board[7],
board.board[8]);
} }
fn main() { fn main() {
let board = TicTacToe { let board = TicTacToe { board: ['.'; 9] };
board: ['.'; 9]
};
display(board); display(board);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment