Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #[derive(Debug)]
  2. enum Direction {
  3. N,
  4. E,
  5. S,
  6. W,
  7. }
  8.  
  9. enum PlayerAction {
  10. Move { direction: Direction, speed: u8 },
  11. Wait,
  12. Attack(Direction),
  13. }
  14.  
  15. fn main() {
  16. let simulated_player_action = PlayerAction::Move {
  17. direction: Direction::W,
  18. speed: 8,
  19. };
  20. match simulated_player_action {
  21. PlayerAction::Wait => println!("Player wants to wait"),
  22. PlayerAction::Move { direction, speed } => println!(
  23. "Player wants to move in direction {:?} with speed {}",
  24. direction, speed
  25. ),
  26. PlayerAction::Attack(direction) => {
  27. println!("Player wants to attack direction {:?}", direction)
  28. }
  29. };
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement