File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -68,15 +68,22 @@ fn main() {
68
68
analyze_slice(&ys[1 .. 4]);
69
69
70
70
// Example of empty slice `&[]`:
71
+ // 空のスライスの例:`&[]`
71
72
let empty_array: [u32; 0] = [];
72
73
assert_eq!(&empty_array, &[]);
73
74
assert_eq!(&empty_array, &[][..]); // Same but more verbose
75
+ // 同じ意味だがより冗長な書き方
74
76
75
77
// Arrays can be safely accessed using `.get`, which returns an
76
78
// `Option`. This can be matched as shown below, or used with
77
79
// `.expect()` if you would like the program to exit with a nice
78
80
// message instead of happily continue.
81
+ // 配列は、`Option`を返す`.get`で安全にアクセスできます。
82
+ // `Option`は以下のようにマッチさせることもできますし、
83
+ // 運よく処理を続ける代わりに、`.expect()`で素敵なメッセージとともに
84
+ // プログラムを終了することもできます。
79
85
for i in 0..xs.len() + 1 { // Oops, one element too far!
86
+ // おっと、1要素余分!
80
87
match xs.get(i) {
81
88
Some(xval) => println!("{}: {}", i, xval),
82
89
None => println!("Slow down! {} is too far!", i),
You can’t perform that action at this time.
0 commit comments