Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- enum Direction {
- N,
- E,
- S,
- W,
- }
- enum PlayerAction {
- Move { direction: Direction, speed: u8 },
- Wait,
- Attack(Direction),
- }
- fn main() {
- let simulated_player_action = PlayerAction::Move {
- direction: Direction::W,
- speed: 8,
- };
- match simulated_player_action {
- PlayerAction::Wait => println!("Player wants to wait"),
- PlayerAction::Move { direction, speed } => println!(
- "Player wants to move in direction {:?} with speed {}",
- direction, speed
- ),
- PlayerAction::Attack(direction) => {
- println!("Player wants to attack direction {:?}", direction)
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement