Skip to content

Commit 01b8470

Browse files
committed
ci: generate pages at 2488fa5 [ci skip]
1 parent 2488fa5 commit 01b8470

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

docs/1.6/book/match.html

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ <h1 class="title">マッチ</h1>
229229

230230
<!-- expression will be evaluated. It’s called `match` because of the term ‘pattern -->
231231

232-
<!-- matching’, which `match` is an implementation of. There’s an [entire section on -->
232+
<!-- matching’, which `match` is an implementation of. There’s a [separate section on -->
233233

234234
<!-- patterns][patterns] that covers all the patterns that are possible here. -->
235235

@@ -239,41 +239,32 @@ <h1 class="title">マッチ</h1>
239239
このような式が <code>match</code> と呼ばれるのは「パターンマッチ」に由来します。
240240
可能なすべてのパターンについて説明した、<a href="patterns.html">パターンの説明のために書かれたセクション</a> が存在します。</p>
241241

242-
<!-- So what’s the big advantage? Well, there are a few. First of all, `match` -->
242+
<!-- One of the many advantages of `match` is it enforces ‘exhaustiveness checking’. -->
243243

244-
<!-- enforces ‘exhaustiveness checking’. Do you see that last arm, the one with the -->
244+
<!-- For example if we remove the last arm with the underscore `_`, the compiler will -->
245245

246-
<!-- underscore (`_`)? If we remove that arm, Rust will give us an error: -->
246+
<!-- give us an error: -->
247247

248-
<p><code>match</code> を使う利点は何でしょうか? いくつか有りますが、
249-
まず一つ目としては <code>match</code> をつかうことで、「網羅性検査」が実施されます。
250-
上のコードで、最後のアンダースコア( <code>_</code> )を用いている腕があるのがわかりますか?
251-
もし、その腕を削除した場合、Rustは以下の様なエラーを発生させます:</p>
248+
<p>数ある <code>match</code> の利点のうちの一つに「網羅性検査」を行なうということが上げられます。
249+
例えば最後の <code>_</code> の腕を消すと、コンパイラはエラーを出します。</p>
252250

253251
<pre><code class="language-text">error: non-exhaustive patterns: `_` not covered
254252
</code></pre>
255253

256-
<!-- In other words, Rust is trying to tell us we forgot a value. Because `x` is an -->
254+
<!-- Rust is telling us that we forgot some value. The compiler infers from `x` that it -->
257255

258-
<!-- integer, Rust knows that it can have a number of different values – for -->
256+
<!-- can have any 32bit integer value; for example -2,147,483,648 to 2,147,483,647. The `_` acts -->
259257

260-
<!-- example, `6`. Without the `_`, however, there is no arm that could match, and -->
258+
<!-- as a 'catch-all', and will catch all possible values that *aren't* specified in -->
261259

262-
<!-- so Rust refuses to compile the code. `_` acts like a ‘catch-all arm’. If none -->
260+
<!-- an arm of `match`. As you can see in the previous example, we provide `match` -->
263261

264-
<!-- of the other arms match, the arm with `_` will, and since we have this -->
262+
<!-- arms for integers 1-5, if `x` is 6 or any other value, then it is caught by `_`. -->
265263

266-
<!-- catch-all arm, we now have an arm for every possible value of `x`, and so our -->
267-
268-
<!-- program will compile successfully. -->
269-
270-
<p>言い換えると、Rustは値を忘れていることを伝えようとしているのです。
271-
なぜなら <code>x</code> は整数であるため、Rustは <code>x</code> は多くの異なる値を取ることができることを知っています。
272-
例えば、 <code>6</code> などがそれにに当たります。
273-
もし <code>_</code> がなかった場合、 <code>6</code> にマッチする腕が存在しない事になります、そのためRustはコンパイルを通しません。
274-
<code>_</code> は「全てキャッチする腕」のように振る舞います。
275-
もし他の腕がどれもマッチしなかった場合、 <code>_</code> の腕が実行されることになります、
276-
この「全てキャッチする腕」が存在するため、 <code>x</code> が取り得るすべての値について対応する腕が存在することになり、コンパイルが成功します。</p>
264+
<p>Rustは何かしらの値を忘れていると教えてくれています。
265+
コンパイラは <code>x</code> が任意の32bitの値、例えば-2,147,483,648から2,147,483,647を取り得ると推論します。
266+
<code>_</code> が「がらくた入れ」として振舞います、 <code>match</code> の腕で指定され <em>なかった</em> 可能な値全てを捕捉します。
267+
先の例で見た通り、 <code>match</code> の腕は 1〜5の値を書いたので、 <code>x</code> が6、あるいは他の値だった時は <code>_</code> に捕捉されます。</p>
277268

278269
<!-- `match` is also an expression, which means we can use it on the right-hand -->
279270

@@ -304,9 +295,12 @@ <h1 class="title">マッチ</h1>
304295
_ <span class='op'>=&gt;</span> <span class='string'>&quot;something else&quot;</span>,
305296
};</pre>
306297

307-
<!-- Sometimes it’s a nice way of converting something from one type to another. -->
298+
<!-- Sometimes it’s a nice way of converting something from one type to another; in -->
308299

309-
<p><code>match</code> はしばしば、ある型からある型へ変換するための良い手段になります。</p>
300+
<!-- this example the integers are converted to `String`. -->
301+
302+
<p><code>match</code> はしばしば、ある型からある型へ変換するための良い手段になります。
303+
この例では整数が <code>String</code> に変換されています。</p>
310304

311305
<!-- # Matching on enums -->
312306

@@ -362,10 +356,12 @@ <h1 id='列挙型に対するマッチ' class='section-header'><a href='#列挙
362356

363357
<!-- have a match arm for every variant of the enum. If you leave one off, it -->
364358

365-
<!-- will give you a compile-time error unless you use `_`. -->
359+
<!-- will give you a compile-time error unless you use `_` or provide all possible -->
360+
361+
<!-- arms. -->
366362

367363
<p>繰り返しになりますが、Rustコンパイラは網羅性のチェックを行い、列挙型のすべてのバリアントに対して、マッチする腕が存在することを要求します。
368-
もし、一つでもマッチする腕のないバリアントを残している場合、 <code>_</code> を用いなければコンパイルエラーが発生します</p>
364+
もし、一つでもマッチする腕のないバリアントを残している場合、 <code>_</code> を用いるか可能な腕を全て書くかしなければコンパイルエラーが発生します</p>
369365

370366
<!-- Unlike the previous uses of `match`, you can’t use the normal `if` -->
371367

0 commit comments

Comments
 (0)