mirror of
https://github.com/rust-lang/book.git
synced 2026-11-30 18:14:33 -06:00
Extra-clarity qualification
Regard the preceding wording “we’ve annotated the types of the values that are returned from these functions for extra clarity.” while only the indexing function is annotated.
This commit is contained in:
@@ -5,7 +5,8 @@ fn main() {
|
||||
let third: &i32 = &v[2];
|
||||
println!("The third element is {}", third);
|
||||
|
||||
match v.get(2) {
|
||||
let third: Option<&i32> = v.get(2);
|
||||
match third {
|
||||
Some(third) => println!("The third element is {}", third),
|
||||
None => println!("There is no third element."),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user