Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Option Match

Create a vector of animals ["cat", "dog", "fish"]. Use match with .get() to look up index 1 and index 5. Print what you find!

Expected output:

text
Index 1: dog
Index 5: not found

Hints:

  • Use animals.get(1) which returns Option<&&str>
  • Match on Some(animal) and None
rust
fn main() {
}