Skip to content

Commit eecaf20

Browse files
authored
Merge pull request #167 from kdnakt/translate-destructure_slice
Translate untranslated lines in destructure_slice.md
2 parents 3126cc8 + 3141e5c commit eecaf20

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
- [match](flow_control/match.md)
121121
- [デストラクト](flow_control/match/destructuring.md)
122122
- [タプル](flow_control/match/destructuring/destructure_tuple.md)
123-
- [arrays/slices](flow_control/match/destructuring/destructure_slice.md)
123+
- [配列とスライス](flow_control/match/destructuring/destructure_slice.md)
124124
- [列挙型](flow_control/match/destructuring/destructure_enum.md)
125125
- [ポインタとref](flow_control/match/destructuring/destructure_pointers.md)
126126
- [構造体](flow_control/match/destructuring/destructure_structures.md)

src/flow_control/match/destructuring.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ A `match` block can destructure items in a variety of ways.
1616
* [Destructuring Structures][struct]
1717
-->
1818
* [タプルのデストラクト][tuple]
19+
* [配列とスライスのデストラクト][slice]
1920
* [列挙型のデストラクト][enum]
2021
* [ポインタのデストラクト][refs]
2122
* [構造体のデストラクト][struct]

src/flow_control/match/destructuring/destructure_slice.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,55 @@
1+
<!--
12
# arrays/slices
3+
-->
4+
# 配列とスライス
25

6+
<!--
37
Like tuples, arrays and slices can be destructured this way:
8+
-->
9+
タプル同様、配列とスライスも以下のようにデストラクトできます:
410

511
```rust,editable
612
fn main() {
713
// Try changing the values in the array, or make it a slice!
14+
// 配列中の値を変更してみましょう。または、スライスにしてみましょう。
815
let array = [1, -2, 6];
916
1017
match array {
1118
// Binds the second and the third elements to the respective variables
19+
// 2番目と3番目の要素を変数にバインドする。
1220
[0, second, third] =>
1321
println!("array[0] = 0, array[1] = {}, array[2] = {}", second, third),
1422
1523
// Single values can be ignored with _
24+
// _で値を無視できる。
1625
[1, _, third] => println!(
1726
"array[0] = 1, array[2] = {} and array[1] was ignored",
1827
third
1928
),
2029
2130
// You can also bind some and ignore the rest
31+
// いくつかの値をバインドして残りを無視できる。
2232
[-1, second, ..] => println!(
2333
"array[0] = -1, array[1] = {} and all the other ones were ignored",
2434
second
2535
),
2636
// The code below would not compile
37+
// 以下のコードはコンパイルできない。
2738
// [-1, second] => ...
2839
2940
// Or store them in another array/slice (the type depends on
3041
// that of the value that is being matched against)
42+
// 別の配列やスライスに値を持たせることもできます。
43+
// (配列かスライスかは、マッチする値の型により異なります)
3144
[3, second, tail @ ..] => println!(
3245
"array[0] = 3, array[1] = {} and the other elements were {:?}",
3346
second, tail
3447
),
3548
3649
// Combining these patterns, we can, for example, bind the first and
3750
// last values, and store the rest of them in a single array
51+
// 例えば、これらのパターンを組み合わせて、
52+
// 最初と最後の値をバインドし、残りの値を配列に持たせることもできます。
3853
[first, middle @ .., last] => println!(
3954
"array[0] = {}, middle = {:?}, array[2] = {}",
4055
first, middle, last
@@ -43,6 +58,12 @@ fn main() {
4358
}
4459
```
4560

61+
<!--
4662
### See also:
63+
-->
64+
### 参照
4765

66+
<!--
4867
[Arrays and Slices](../../../primitives/array.md) and [Binding](../binding.md) for `@` sigil
68+
-->
69+
[配列とスライス](../../../primitives/array.md)、@マークについては[バインディング](../binding.md)

0 commit comments

Comments
 (0)