Skip to content

Commit beca229

Browse files
committed
ci: generate pages at 65a47c9 [ci skip]
1 parent 65a47c9 commit beca229

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

docs/1.6/book/match.html

Lines changed: 28 additions & 24 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 a [separate section on -->
232+
<!-- matching’, which `match` is an implementation of. There’s an [entire section on -->
233233

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

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

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

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

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

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

251253
<pre><code class="language-text">error: non-exhaustive patterns: `_` not covered
252254
</code></pre>
253255

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

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

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

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

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

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>
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>
268277

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

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

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

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

305311
<!-- # Matching on enums -->
306312

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

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

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

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

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

0 commit comments

Comments
 (0)