Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Coord {
- x: i8,
- y: i8,
- }
- struct GameBoard {
- board: [[char; 3]; 3],
- mine: Coord,
- }
- impl GameBoard {
- fn new() -> GameBoard {
- // Generate the mine position
- let x = rand::thread_rng().gen_range(0, 2);
- let y = rand::thread_rng().gen_range(0, 2);
- GameBoard {
- board: [
- [O, O, O],
- [O, O, O],
- [O, O, O]
- ],
- mine: Coord {x: x, y: y},
- }
- }
- }
- fn update_board(game_board: &mut GameBoard, coord: &Coord) {
- if game_board.mine.x == coord.x && game_board.mine.y == coord.y {
- // error: the trait `core::ops::Index<i8>` is not implemented for the type `[[char; 3]]` [E0277]
- game_board.board[coord.x][coord.y] = BOMB;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement