]>
Commit | Line | Data |
---|---|---|
74b04a01 XL |
1 | fn main() { |
2 | // ANCHOR: here | |
923072b8 | 3 | let v = vec![1, 2, 3, 4, 5]; |
74b04a01 | 4 | |
923072b8 | 5 | let third: &i32 = &v[2]; |
2b03887a | 6 | println!("The third element is {third}"); |
923072b8 FG |
7 | |
8 | let third: Option<&i32> = v.get(2); | |
9 | match third { | |
2b03887a | 10 | Some(third) => println!("The third element is {third}"), |
923072b8 FG |
11 | None => println!("There is no third element."), |
12 | } | |
13 | // ANCHOR_END: here | |
74b04a01 | 14 | } |