Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. struct Coord {
  2. x: i8,
  3. y: i8,
  4. }
  5.  
  6. struct GameBoard {
  7. board: [[char; 3]; 3],
  8. mine: Coord,
  9. }
  10.  
  11. impl GameBoard {
  12. fn new() -> GameBoard {
  13. // Generate the mine position
  14. let x = rand::thread_rng().gen_range(0, 2);
  15. let y = rand::thread_rng().gen_range(0, 2);
  16.  
  17. GameBoard {
  18. board: [
  19. [O, O, O],
  20. [O, O, O],
  21. [O, O, O]
  22. ],
  23. mine: Coord {x: x, y: y},
  24. }
  25. }
  26. }
  27.  
  28. fn update_board(game_board: &mut GameBoard, coord: &Coord) {
  29. if game_board.mine.x == coord.x && game_board.mine.y == coord.y {
  30. // error: the trait `core::ops::Index<i8>` is not implemented for the type `[[char; 3]]` [E0277]
  31. game_board.board[coord.x][coord.y] = BOMB;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement