Exerpad
🔥 0
0 XP
Exercise 1 · Chapter: Enums & Pattern MatchingRequired+50 XP

Traffic Light

Define an enum called TrafficLight with three variants: Red, Yellow, and Green.

Create a variable set to TrafficLight::Red and use match to print:

  • Red => Stop
  • Yellow => Slow down
  • Green => Go

Expected output:

Stop

rust
fn main() {
}
Output
Run your code to see the output here.