Array2ds is a none-bloated library in rust for rust by rust for handling staticly sized 2d array/grids to run the examples: cargo run --example 'example_name'
```rust use array2ds::array2d::*; use std::io::stdin;
struct Square { data: char, }
impl Default for Square { fn default() -> Self { Square { data: '#' } } }
fn main() { run_game(); }
fn rungame() {
let mut board: Array2d0 1
, row: 0 column 1");
printboard(&board);
let mut winner = false;
let mut current_player = 'X';
while !winner {
let (row, column) = read_grid_location();
if board[[row, column]].data == '#' {
board[[row, column]].data = current_player;
match current_player {
'X' => current_player = 'O',
'O' => current_player = 'X',
_ => panic!("invalid data for square"),
}
println!();
print_board(&board);
winner = check_horizontal(&board) || check_vertical(&board) || check_diagnol(&board);
} else {
println!("invalid location, try another");
}
}
}
fn readgridlocation() -> (usize, usize) {
let mut buffer = String::new();
stdin().read_line(&mut buffer).unwrap();
let buffer = buffer.trim();
let splitted: Vec<&str> = buffer.split(' ').collect();
if splitted.len() < 2 {
panic!("enter data as row col
");
}
let r = splitted[0].parse::
fn check_diagnol(board: &Array2d
let mid = &board[(1,1)];
if mid.data == '#'{
return false
}
if board[[0,0]].data == mid.data && mid.data == board[(2,2)].data{
return true
}
if board[[2,0]].data == mid.data && mid.data == board[(0,2)].data{
return true
}
false
}
fn checkvertical(board: &Array2d
if x_count == 3 || o_count == 3 {
return true;
}
}
false
}
fn checkhorizontal(board: &Array2d
fn printboard(board: &Array2d
```
MIT