Skip to content

Commit 46e9578

Browse files
authored
Merge pull request #271 from leque/fix-patterns
fix patterns.md
2 parents 7aeaa9f + e69cb76 commit 46e9578

File tree

3 files changed

+66
-66
lines changed

3 files changed

+66
-66
lines changed

1.6/ja/book/patterns.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<!-- We use them in [variable
88
bindings][bindings], [match statements][match], and other places, too.-->
9-
パターンは [変数束縛][bindings], [マッチ文][match] などで使われています。
9+
パターンは [変数束縛][bindings] [マッチ文][match] などで使われています。
1010

1111
<!--Let’s go on a whirlwind tour of all of the things patterns can do!-->
1212
さあ、めくるめくパターンの旅を始めましょう!
@@ -33,7 +33,7 @@ match x {
3333
これは `one` を表示します。
3434

3535
<!-- There’s one pitfall with patterns: like anything that introduces a new binding,they introduce shadowing. For example: -->
36-
パターンには一つ落とし穴があります。新しい束縛を導入すると、他の束縛を導入するものと同じように、シャドーイングします。例えば:
36+
パターンには一つ落とし穴があります。新しい束縛を導入する他の構文と同様、パターンはシャドーイングをします。例えば:
3737

3838
```rust
3939
let x = 'x';
@@ -47,7 +47,7 @@ println!("x: {}", x)
4747
```
4848

4949
<!-- This prints:-->
50-
これの結果は以下のようになります:
50+
これは以下のように出力します。
5151

5252
```text
5353
x: c c: c
@@ -57,13 +57,13 @@ x: x
5757
<!-- In other words, `x =>` matches the pattern and introduces a new binding named
5858
`x` that’s in scope for the match arm. Because we already have a binding named
5959
`x`, this new `x` shadows it. -->
60-
別の言い方をすると、 `x =>` はパターンへのマッチだけでなく、マッチの腕内で有効な `x` という名前の束縛を導入します。既に `x` は束縛されていたので、この新しい `x` はそれを覆い隠します
60+
別の言い方をすると、 `x =>` は値をパターンにマッチさせ、マッチの腕内で有効な `x` という名前の束縛を導入します。既に `x` という束縛が存在していたので、新たに導入した `x` は、その古い `x` をシャドーイングします
6161

6262
<!-- # Multiple patterns -->
6363
# 複式パターン
6464

6565
<!-- You can match multiple patterns with `|`: -->
66-
`|` を使うと、複式パターンが導入できます
66+
`|` を使うと、複数のパターンにマッチさせることができます
6767

6868

6969
```rust
@@ -80,11 +80,11 @@ match x {
8080
これは、 `one or two` を出力します。
8181

8282
<!-- # Destructuring -->
83-
# デストラクチャリング
83+
# 分配束縛
8484

8585
<!-- If you have a compound data type, like a [`struct`][struct], you can destructure it
8686
inside of a pattern: -->
87-
例えば [`struct`][struct] のような複合データ型を作成したいとき、パターン内でデータを分解することができます
87+
[`struct`][struct] のような複合データ型が存在するとき、パターン内でその値を分解することができます
8888

8989
```rust
9090
struct Point {
@@ -118,7 +118,7 @@ match origin {
118118
```
119119

120120
<!-- If we only care about some of the values, we don’t have to give them all names: -->
121-
値の一部だけを扱いたい場合は、値の全てに名前を付ける必要はありません
121+
値の一部にだけ興味がある場合は、値のすべてに名前を付ける必要はありません
122122

123123
```rust
124124
struct Point {
@@ -137,7 +137,7 @@ match origin {
137137
これは `x is 0` を出力します。
138138

139139
<!-- You can do this kind of match on any member, not just the first:-->
140-
どのメンバに対してもこの種のマッチを行うことができます。たとえ最初ではなくても:
140+
最初のメンバだけでなく、どのメンバに対してもこの種のマッチを行うことができます。
141141

142142
```rust
143143
struct Point {
@@ -157,7 +157,7 @@ match origin {
157157

158158
<!-- This ‘destructuring’ behavior works on any compound data type, like
159159
[tuples][tuples] or [enums][enums]. -->
160-
この「デストラクチャリング(destructuring)と呼ばれる振る舞いは、 [タプル][tuples][列挙型][enums] のような、複合データ型で使用できます
160+
この「分配束縛」 (destructuring) と呼ばれる振る舞いは、 [タプル][tuples][列挙型][enums] のような、任意の複合データ型で使用できます
161161

162162
[tuples]: primitive-types.html#tuples
163163
[enums]: enums.html
@@ -169,7 +169,7 @@ match origin {
169169
パターン内の型や値を無視するために `_` を使うことができます。
170170

171171
<!-- For example, here’s a `match` against a `Result<T, E>`: -->
172-
例として、 `Result<T, E>` に対して `match` を適用してみましょう
172+
例として、 `Result<T, E>` に対して `match` をしてみましょう
173173

174174
```rust
175175
# let some_value: Result<i32, &'static str> = Err("There was an error");
@@ -182,11 +182,11 @@ match some_value {
182182
<!-- In the first arm, we bind the value inside the `Ok` variant to `value`. But
183183
in the `Err` arm, we use `_` to disregard the specific error, and just print
184184
a general error message. -->
185-
最初の部分では `Ok` ヴァリアント内の値を `value` に結びつけています。しかし `Err` 部分では、特定のエラーを避けて、標準的なエラーメッセージを表示するために `_` を使っています。
185+
最初の部分では `Ok` ヴァリアント内の値に `value` を束縛しています。しかし `Err` 部分では、ヴァリアント内のエラー情報を無視して一般的なエラーメッセージを表示するために `_` を使っています。
186186

187187
<!-- `_` is valid in any pattern that creates a binding. This can be useful to
188188
ignore parts of a larger structure: -->
189-
`_` は束縛を伴うどんなパターンにおいても有効です。これは大きな構造の一部分を無視する際に有用です
189+
`_` は束縛を導入するどのようなパターンにおいても有効です。これは大きな構造の一部を無視する際に有用です
190190

191191
```rust
192192
fn coordinate() -> (i32, i32, i32) {
@@ -200,7 +200,7 @@ let (x, _, z) = coordinate();
200200

201201
<!-- Here, we bind the first and last element of the tuple to `x` and `z`, but
202202
ignore the middle element. -->
203-
ここでは、タプルの最初と最後の要素を `x``z` に結びつけています
203+
ここでは、タプルの最初と最後の要素に `x``z` を束縛します
204204

205205
<!-- Similarly, you can use `..` in a pattern to disregard multiple values. -->
206206
同様に `..` でパターン内の複数の値を無視することができます。
@@ -226,7 +226,7 @@ match x {
226226
# ref と ref mut
227227

228228
<!-- If you want to get a [reference][ref], use the `ref` keyword:-->
229-
もし [リファレンス][ref] を取得したいときは `ref` キーワードを使いましょう。
229+
[参照][ref] を取得したいときは `ref` キーワードを使いましょう。
230230

231231
```rust
232232
let x = 5;
@@ -244,7 +244,7 @@ match x {
244244
<!-- Here, the `r` inside the `match` has the type `&i32`. In other words, the `ref`
245245
keyword _creates_ a reference, for use in the pattern. If you need a mutable
246246
reference, `ref mut` will work in the same way: -->
247-
ここで `match` 内の `r``&i32` 型を持っています。言い換えると `ref` キーワードがリファレンスを _作ります_
247+
ここで `match` 内の `r``&i32` 型を持っています。言い換えると `ref` キーワードはパターン内で使う参照を _作り出します_ 。ミュータブルな参照が必要な場合は、同様に `ref mut` を使います
248248

249249
```rust
250250
let mut x = 5;
@@ -255,10 +255,10 @@ match x {
255255
```
256256

257257
<!-- # Ranges -->
258-
# レンジ
258+
# 範囲
259259

260260
<!-- You can match a range of values with `...`: -->
261-
`...` で値のレンジのマッチを行うことができます
261+
`...` で値の範囲をマッチさせることができます
262262

263263
```rust
264264
let x = 1;
@@ -273,7 +273,7 @@ match x {
273273
これは `one through five` を出力します。
274274

275275
<!-- Ranges are mostly used with integers and `char`s: -->
276-
レンジは大体、整数か `char` 型で使われます:
276+
範囲は多くの場合、整数か `char` 型で使われます:
277277

278278
```rust
279279
let x = '💅';
@@ -292,7 +292,7 @@ match x {
292292
# 束縛
293293

294294
<!-- You can bind values to names with `@`: -->
295-
`@` で値を名前と結びつけることができます
295+
`@` で値に名前を束縛することができます
296296

297297
```rust
298298
let x = 1;
@@ -306,7 +306,7 @@ match x {
306306
<!-- This prints `got a range element 1`. This is useful when you want to
307307
do a complicated match of part of a data structure: -->
308308
これは `got a range element 1` を出力します。
309-
データ構造の一部に対する複雑なマッチが欲しいときに有用です
309+
データ構造の一部に対して複雑なマッチングをしたいときに有用です
310310

311311
```rust
312312
#[derive(Debug)]
@@ -323,11 +323,11 @@ match x {
323323
```
324324

325325
<!--This prints `Some("Steve")`: we’ve bound the inner `name` to `a`.-->
326-
これは `Some("Steve")` を出力します。内側の `name` `a` に結びつけます
326+
これは `Some("Steve")` を出力します。内側の `name` の値への参照に `a` を束縛します
327327

328328
<!-- If you use `@` with `|`, you need to make sure the name is bound in each part
329329
of the pattern: -->
330-
もし `|``@` を使うときは、パターンのそれぞれの部分が名前と結びついているか確認する必要があります
330+
`@``|` と組み合わせて使う場合は、それぞれのパターンで同じ名前が束縛されるようにする必要があります
331331

332332
```rust
333333
let x = 5;
@@ -363,7 +363,7 @@ match x {
363363
これは `Got an int!` を出力します。
364364

365365
<!--If you’re using `if` with multiple patterns, the `if` applies to both sides:-->
366-
複式パターンで `if` を使うと、 `if` は両方に適用されます
366+
複式パターンで `if` を使うと、 `if` `|` の両側に適用されます
367367

368368
```rust
369369
let x = 4;
@@ -377,7 +377,7 @@ match x {
377377

378378
<!--This prints `no`, because the `if` applies to the whole of `4 | 5`, and not to
379379
just the `5`. In other words, the precedence of `if` behaves like this: -->
380-
これは `no` を出力します。なぜなら `if``4 | 5` 全体に適用されるのであって、 `5` 単独に対してではないからです。つまり `if` 節は以下のように振舞います:
380+
これは `no` を出力します。なぜなら `if``4 | 5` 全体に適用されるのであって、 `5` 単独に対して適用されるのではないからです。つまり `if` 節は以下のように振舞います:
381381

382382
```text
383383
(4 | 5) if y => ...
@@ -395,7 +395,7 @@ just the `5`. In other words, the precedence of `if` behaves like this: -->
395395

396396
<!--Whew! That’s a lot of different ways to match things, and they can all be
397397
mixed and matched, depending on what you’re doing: -->
398-
ふう、マッチには様々な方法があるのですね。やりたいこと次第で、それらを混ぜてマッチさせることもできます:
398+
ふう、マッチには様々な方法があるのですね。やりたいことに応じて、それらを混ぜてマッチさせることもできます:
399399

400400
```rust,ignore
401401
match x {

0 commit comments

Comments
 (0)