mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-23 04:29:41 +00:00
@ -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
|
||||||
@ -99,4 +99,4 @@ fn main() {
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> You can find the solutions [here](https://github.com/sunface/rust-by-practice/blob/master/solutions/compound-types/array.md)(under the solutions path), but only use it when you need it
|
> You can find the solutions [here](https://github.com/sunface/rust-by-practice/blob/master/solutions/compound-types/array.md)(under the solutions path), but only use it when you need it
|
||||||
|
Reference in New Issue
Block a user