]> git.proxmox.com Git - rustc.git/blame - src/doc/book/listings/ch08-common-collections/listing-08-04/src/main.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / doc / book / listings / ch08-common-collections / listing-08-04 / src / main.rs
CommitLineData
74b04a01
XL
1fn 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}