@@ -196,41 +196,41 @@ This code prints `one or two`.
196
196
このコードは、` one or two ` を出力します。
197
197
198
198
<!--
199
- ### Matching Ranges of Values with `... `
199
+ ### Matching Ranges of Values with `..= `
200
200
-->
201
201
202
- ### ` ... ` で値の範囲に合致させる
202
+ ### ` ..= ` で値の範囲に合致させる
203
203
204
204
<!--
205
- The `... ` syntax allows us to match to an inclusive range of values. In the
205
+ The `..= ` syntax allows us to match to an inclusive range of values. In the
206
206
following code, when a pattern matches any of the values within the range, that
207
207
arm will execute:
208
208
-->
209
209
210
- ` ... ` 記法により、限度値を含む値の範囲にマッチさせることができます。以下のコードでは、
210
+ ` ..= ` 記法により、限度値を含む値の範囲にマッチさせることができます。以下のコードでは、
211
211
パターンが範囲内のどれかの値に合致すると、そのアームが実行されます:
212
212
213
213
``` rust
214
214
let x = 5 ;
215
215
216
216
match x {
217
217
// 1から5まで
218
- 1 ... 5 => println! (" one through five" ),
218
+ 1 ..= 5 => println! (" one through five" ),
219
219
// それ以外
220
220
_ => println! (" something else" ),
221
221
}
222
222
```
223
223
224
224
<!--
225
225
If `x` is 1, 2, 3, 4, or 5, the first arm will match. This syntax is more
226
- convenient than using the `|` operator to express the same idea; instead of `1
227
- ... 5`, we would have to specify `1 | 2 | 3 | 4 | 5` if we used `|`. Specifying
226
+ convenient than using the `|` operator to express the same idea; instead of `1..=5`,
227
+ we would have to specify `1 | 2 | 3 | 4 | 5` if we used `|`. Specifying
228
228
a range is much shorter, especially if we want to match, say, any number
229
229
between 1 and 1,000!
230
230
-->
231
231
232
232
` x ` が1、2、3、4か5なら、最初のアームが合致します。この記法は、` | ` 演算子を使用して同じ考えを表現するより便利です;
233
- ` 1 ... 5 ` ではなく、` | ` を使用したら、` 1 | 2 | 3 | 4 | 5 ` と指定しなければならないでしょう。
233
+ ` 1..= 5 ` ではなく、` | ` を使用したら、` 1 | 2 | 3 | 4 | 5 ` と指定しなければならないでしょう。
234
234
範囲を指定する方が遥かに短いのです。特に1から1000までの値と合致させたいとかなら!
235
235
236
236
<!--
@@ -253,9 +253,9 @@ let x = 'c';
253
253
254
254
match x {
255
255
// ASCII文字前半
256
- 'a' ... 'j' => println! (" early ASCII letter" ),
256
+ 'a' ..= 'j' => println! (" early ASCII letter" ),
257
257
// ASCII文字後半
258
- 'k' ... 'z' => println! (" late ASCII letter" ),
258
+ 'k' ..= 'z' => println! (" late ASCII letter" ),
259
259
// それ以外
260
260
_ => println! (" something else" ),
261
261
}
@@ -1544,14 +1544,14 @@ were applied only to the final value in the list of values specified using the
1544
1544
The *at* operator (`@`) lets us create a variable that holds a value at the
1545
1545
same time we’re testing that value to see whether it matches a pattern. Listing
1546
1546
18-32 shows an example where we want to test that a `Message::Hello` `id` field
1547
- is within the range `3... 7`. But we also want to bind the value to the variable
1547
+ is within the range `3..= 7`. But we also want to bind the value to the variable
1548
1548
`id_variable` so we can use it in the code associated with the arm. We could
1549
1549
name this variable `id`, the same as the field, but for this example we’ll use
1550
1550
a different name.
1551
1551
-->
1552
1552
1553
1553
* at* 演算子(` @ ` )により、値を保持する変数を生成するのと同時にその値がパターンに一致するかを調べることができます。
1554
- リスト18-32は、` Message::Hello ` の` id ` フィールドが範囲` 3... 7 ` にあるかを確かめたいという例です。
1554
+ リスト18-32は、` Message::Hello ` の` id ` フィールドが範囲` 3..= 7 ` にあるかを確かめたいという例です。
1555
1555
しかし、アームに紐づいたコードで使用できるように変数` id_variable ` に値を束縛もしたいです。この変数をフィールドと同じ、
1556
1556
` id ` と名付けることもできますが、この例では異なる名前にします。
1557
1557
@@ -1563,11 +1563,11 @@ enum Message {
1563
1563
let msg = Message :: Hello { id : 5 };
1564
1564
1565
1565
match msg {
1566
- Message :: Hello { id : id_variable @ 3 ... 7 } => {
1566
+ Message :: Hello { id : id_variable @ 3 ..= 7 } => {
1567
1567
// 範囲内のidが見つかりました: {}
1568
1568
println! (" Found an id in range: {}" , id_variable )
1569
1569
},
1570
- Message :: Hello { id : 10 ... 12 } => {
1570
+ Message :: Hello { id : 10 ..= 12 } => {
1571
1571
// 別の範囲内のidが見つかりました
1572
1572
println! (" Found an id in another range" )
1573
1573
},
@@ -1587,11 +1587,11 @@ while also testing it</span>
1587
1587
1588
1588
<!--
1589
1589
This example will print `Found an id in range: 5`. By specifying `id_variable
1590
- @` before the range `3... 7`, we’re capturing whatever value matched the range
1590
+ @` before the range `3..= 7`, we’re capturing whatever value matched the range
1591
1591
while also testing that the value matched the range pattern.
1592
1592
-->
1593
1593
1594
- この例は、` Found an id in range: 5 ` と出力します。範囲` 3... 7 ` の前に` id_variable @ ` と指定することで、
1594
+ この例は、` Found an id in range: 5 ` と出力します。範囲` 3..= 7 ` の前に` id_variable @ ` と指定することで、
1595
1595
値が範囲パターンに一致することを確認しつつ、範囲にマッチしたどんな値も捕捉しています。
1596
1596
1597
1597
<!--
0 commit comments