If Let Option
Use if let to check if a vector has an element at index 2. If it does, print it. If not, print a fallback message.
Expected output:
text
Found: cherry
Hints:
- Create
vec!["apple", "banana", "cherry"] - Use
if let Some(fruit) = fruits.get(2) { ... } - The
elsebranch handlesNone
rust
fn main() {
}