mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-23 20:49:41 +00:00
Update Q6 array.md
changed comment suggesting arr.get() return Option<T> to Option<&T>
This commit is contained in:
@ -88,7 +88,7 @@ fn main() {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let names = [String::from("Sunfei"), "Sunface".to_string()];
|
let names = [String::from("Sunfei"), "Sunface".to_string()];
|
||||||
|
|
||||||
// `Get` returns an Option<T>, it's safe to use
|
// `Get` returns an Option<&T>, it's safe to use
|
||||||
let name0 = names.get(0).unwrap();
|
let name0 = names.get(0).unwrap();
|
||||||
|
|
||||||
// But indexing is not safe
|
// But indexing is not safe
|
||||||
|
Reference in New Issue
Block a user