Unwrap or Default
Create an empty vector of type Vec<i32>. Try to get the first element using .get(0) and use .unwrap_or() to provide &0 as a default. Print the result.
Expected output:
text
Value: 0
Hints:
- Create an empty vector:
let numbers: Vec<i32> = vec![]; - Use
.get(0).unwrap_or(&0)to get a safe default
rust
fn main() {
}