]> git.lizzy.rs Git - rust.git/blob - src/doc/po/ja/tutorial.md.po
doc: Remove all uses of `~str` from the documentation.
[rust.git] / src / doc / po / ja / tutorial.md.po
1 # Japanese translations for Rust package
2 # Copyright (C) 2013 The Rust Project Developers
3 # This file is distributed under the same license as the Rust package.
4 # Automatically generated, 2013.
5 #
6 msgid ""
7 msgstr ""
8 "Project-Id-Version: Rust 0.8\n"
9 "POT-Creation-Date: 2014-02-03 08:13+0900\n"
10 "PO-Revision-Date: 2013-08-08 22:27+0900\n"
11 "Last-Translator: Automatically generated\n"
12 "Language-Team: none\n"
13 "Language: ja\n"
14 "MIME-Version: 1.0\n"
15 "Content-Type: text/plain; charset=UTF-8\n"
16 "Content-Transfer-Encoding: UTF-8\n"
17 "Plural-Forms: nplurals=1; plural=0;\n"
18
19 #. type: Plain text
20 #: src/doc/guide-conditions.md:4 src/doc/guide-ffi.md:4
21 #: src/doc/guide-lifetimes.md:4 src/doc/guide-macros.md:4
22 #: src/doc/guide-tasks.md:4 src/doc/rust.md:4 src/doc/tutorial.md:4
23 msgid "# Introduction"
24 msgstr "# イントロダクション"
25
26 #. type: Plain text
27 #: src/doc/guide-ffi.md:168 src/doc/tutorial.md:885
28 msgid "# Destructors"
29 msgstr "# デストラクタ"
30
31 #. type: Plain text
32 #: src/doc/guide-lifetimes.md:72 src/doc/tutorial.md:1409
33 msgid "Now we can call `compute_distance()` in various ways:"
34 msgstr ""
35 "上記の `compute_distance()` 関数は、様々な方法で呼び出すことができます。"
36
37 #. type: Plain text
38 #: src/doc/guide-pointers.md:326 src/doc/tutorial.md:1360
39 #, fuzzy
40 msgid "# References"
41 msgstr "# ポインタのデリファレンス"
42
43 #. type: Plain text
44 #: src/doc/guide-testing.md:127 src/doc/tutorial.md:786
45 #, fuzzy
46 msgid "For example:"
47 msgstr "## 最小限の例"
48
49 #. type: Plain text
50 #: src/doc/rust.md:1391 src/doc/tutorial.md:2495
51 msgid "Likewise, supertrait methods may also be called on trait objects."
52 msgstr ""
53 "同様に、スーパートレイトのメソッドは、トレイトオブジェクトについても呼び出す"
54 "ことが可能です。"
55
56 #. type: Plain text
57 #: src/doc/tutorial.md:2
58 msgid "% The Rust Language Tutorial"
59 msgstr "% Rust 言語チュートリアル"
60
61 #. type: Plain text
62 #: src/doc/tutorial.md:13
63 msgid ""
64 "Rust is a programming language with a focus on type safety, memory safety, "
65 "concurrency and performance. It is intended for writing large-scale, high-"
66 "performance software that is free from several classes of common errors. "
67 "Rust has a sophisticated memory model that encourages efficient data "
68 "structures and safe concurrency patterns, forbidding invalid memory accesses "
69 "that would otherwise cause segmentation faults. It is statically typed and "
70 "compiled ahead of time."
71 msgstr ""
72 "Rust は、型安全性、メモリ安全性、並列性、パフォーマンスを重視したプログラミン"
73 "グ言語です。大規模でハイパフォーマンスなソフトウェア作成向きの、C++ 等の言語"
74 "でよくある誤りを犯しにくい言語仕様になっています。Rust の洗練されたメモリモデ"
75 "ルでは、効率的なデータ構造や安全な並行計算を実現することが可能であり、セグメ"
76 "ンテーション違反を引き起こす不正なメモリアクセスは起こりえません。Rust は、静"
77 "的型付けされた、コンパイル型の言語です。"
78
79 #. type: Plain text
80 #: src/doc/tutorial.md:17
81 msgid ""
82 "As a multi-paradigm language, Rust supports writing code in procedural, "
83 "functional and object-oriented styles. Some of its pleasant high-level "
84 "features include:"
85 msgstr ""
86 "Rust はマルチパラダイム言語であり、手続き型、関数型、オブジェクト指向型のプロ"
87 "グラミングをサポートします。Rust には、次のような素敵で高レベルな特徴がありま"
88 "す。"
89
90 #. type: Bullet: '* '
91 #: src/doc/tutorial.md:30
92 msgid ""
93 "**Type inference.** Type annotations on local variable declarations are "
94 "optional."
95 msgstr ""
96 "**型推論:** ローカル変数の宣言では型注釈 (type annotation) を省略できます。"
97
98 #. type: Bullet: '* '
99 #: src/doc/tutorial.md:30
100 msgid ""
101 "**Safe task-based concurrency.** Rust's lightweight tasks do not share "
102 "memory, instead communicating through messages."
103 msgstr ""
104 "**タスクベースの安全な並行計算:** Rust の軽量タスクはタスク間でメモリを共有す"
105 "るのではなく、メッセージを介して通信します。"
106
107 #. type: Bullet: '* '
108 #: src/doc/tutorial.md:30
109 msgid ""
110 "**Higher-order functions.** Efficient and flexible closures provide "
111 "iteration and other control structures"
112 msgstr ""
113 "**高階関数:** 効率的で柔軟なクロージャにより、イテレーションやその他の制御構"
114 "造を実現できます。"
115
116 #. type: Bullet: '* '
117 #: src/doc/tutorial.md:30
118 msgid ""
119 "**Pattern matching and algebraic data types.** Pattern matching on Rust's "
120 "enumeration types (a more powerful version of C's enums, similar to "
121 "algebraic data types in functional languages) is a compact and expressive "
122 "way to encode program logic."
123 msgstr ""
124 "**パターンマッチと代数的データ型:** Rust の列挙型 (C の列挙型の強化バージョ"
125 "ン。関数型言語における代数的データ型のようなもの) のパターンマッチにより、プ"
126 "ログラムの論理を、コンパクトで表現力豊かに記述することができます。"
127
128 #. type: Bullet: '* '
129 #: src/doc/tutorial.md:30
130 msgid ""
131 "**Polymorphism.** Rust has type-parametric functions and types, type classes "
132 "and OO-style interfaces."
133 msgstr ""
134 "**ポリモーフィズム:** Rust には、型パラメータをもつ関数や型、型クラスとオブ"
135 "ジェクト指向風のインターフェースがあります。"
136
137 #. type: Plain text
138 #: src/doc/tutorial.md:32
139 msgid "## Scope"
140 msgstr "## 本文書の位置づけ"
141
142 #. type: Plain text
143 #: src/doc/tutorial.md:38
144 msgid ""
145 "This is an introductory tutorial for the Rust programming language. It "
146 "covers the fundamentals of the language, including the syntax, the type "
147 "system and memory model, generics, and modules. [Additional tutorials](#what-"
148 "next) cover specific language features in greater depth."
149 msgstr ""
150 "この文章は、Rust プログラミング言語のチュートリアルです。構文、型システムとメ"
151 "モリモデル、ジェネリクス、モジュールなどの言語の基礎となる部分をカバーしてい"
152 "ます。 いくつかの言語機能の詳細については、 [その他のチュートリアル](#次のス"
153 "テップは) を参照してください。"
154
155 #. type: Plain text
156 #: src/doc/tutorial.md:42
157 msgid ""
158 "This tutorial assumes that the reader is already familiar with one or more "
159 "languages in the C family. Understanding of pointers and general memory "
160 "management techniques will help."
161 msgstr ""
162 "本チュートリアルは、読者がすでに 1 つ以上の C 系統言語 に精通していることを前"
163 "提としています。本書を理解する上で、ポインタやメモリ管理のテクニックに関する"
164 "知識が役に立つでしょう。"
165
166 #. type: Plain text
167 #: src/doc/tutorial.md:44
168 msgid "## Conventions"
169 msgstr "## 本書の表記について"
170
171 #. type: Plain text
172 #: src/doc/tutorial.md:47
173 msgid ""
174 "Throughout the tutorial, language keywords and identifiers defined in "
175 "example code are displayed in `code font`."
176 msgstr ""
177 "本チュートリアルでは、言語のキーワードや、サンプルコード中で定義される識別子"
178 "を `code font` のように示します。"
179
180 #. type: Plain text
181 #: src/doc/tutorial.md:53
182 msgid ""
183 "Code snippets are indented, and also shown in a monospaced font. Not all "
184 "snippets constitute whole programs. For brevity, we'll often show fragments "
185 "of programs that don't compile on their own. To try them out, you might have "
186 "to wrap them in `fn main() { ... }`, and make sure they don't contain "
187 "references to names that aren't actually defined."
188 msgstr ""
189 "コードスニペットは、インデントされ、固定幅フォントで表示されます。いくつかの"
190 "コードスニペットは、プログラムの一部を抜き出したものになっています。説明を簡"
191 "潔にするため、それだけではコンパイル不可能なプログラムの断片を掲載することが"
192 "あります。プログラムの動作を試す際には、全体を `fn main() { ... }` で囲んでく"
193 "ださい。また、プログラム中で未定義の名前を参照している箇所がないか確認してく"
194 "ださい。"
195
196 #. type: Plain text
197 #: src/doc/tutorial.md:57
198 msgid ""
199 "> *Warning:* Rust is a language under ongoing development. Notes > about "
200 "potential changes to the language, implementation > deficiencies, and other "
201 "caveats appear offset in blockquotes."
202 msgstr ""
203 "> *警告:* Rust は開発途上の言語です。将来予定されている言語への変更や、実"
204 "装上の不備、その他の注意事項など、 blockquote の段落 (この段落もそうです) に"
205 "注意してください。"
206
207 #. type: Plain text
208 #: src/doc/tutorial.md:59
209 msgid "# Getting started"
210 msgstr "# はじめに"
211
212 #. type: Plain text
213 #: src/doc/tutorial.md:67
214 #, fuzzy
215 #| msgid ""
216 #| "The Rust compiler currently must be built from a [tarball], unless you "
217 #| "are on Windows, in which case using the [installer][win-exe] is "
218 #| "recommended."
219 msgid ""
220 "The Rust compiler currently must be built from a [tarball] or [git], unless "
221 "you are on Windows, in which case using the [installer][win-exe] is "
222 "recommended. There is a list of community-maintained nightly builds and "
223 "packages [on the wiki][wiki-packages]."
224 msgstr ""
225 "Windows 以外の環境では、今のところ、Rust のコンパイラは [ソースコード]"
226 "[tarball] からビルドする必要があります。Windows をお使いの場合は、 [インス"
227 "トーラー][win-exe] の使用をおすすめします。"
228
229 #. type: Plain text
230 #: src/doc/tutorial.md:72
231 #, fuzzy
232 #| msgid ""
233 #| "Since the Rust compiler is written in Rust, it must be built by a "
234 #| "precompiled \"snapshot\" version of itself (made in an earlier state of "
235 #| "development). As such, source builds require a connection to the "
236 #| "Internet, to fetch snapshots, and an OS that can execute the available "
237 #| "snapshot binaries."
238 msgid ""
239 "Since the Rust compiler is written in Rust, it must be built by a "
240 "precompiled \"snapshot\" version of itself (made in an earlier state of "
241 "development). The source build automatically fetches these snapshots from "
242 "the Internet on our supported platforms."
243 msgstr ""
244 "Rust のコンパイラは Rust で書かれているため、最新版の少し前のソースからコンパ"
245 "イルされた「スナップショット」版コンパイラでビルドする必要があります。スナッ"
246 "プショットを利用してビルドするためには、スナップショットをダウンロードするた"
247 "めのインターネット接続と、スナップショットバイナリを実行できる OS が必要で"
248 "す。"
249
250 #. type: Plain text
251 #: src/doc/tutorial.md:74
252 msgid "Snapshot binaries are currently built and tested on several platforms:"
253 msgstr ""
254 "スナップショットバイナリは、現時点では以下のプラットフォーム向けのものがあり"
255 "ます。"
256
257 #. type: Bullet: '* '
258 #: src/doc/tutorial.md:78
259 #, fuzzy
260 #| msgid "Windows (7, Server 2008 R2), x86 only"
261 msgid "Windows (7, 8, Server 2008 R2), x86 only"
262 msgstr "Windows (7, Server 2008 R2), x86 のみ"
263
264 #. type: Bullet: '* '
265 #: src/doc/tutorial.md:78
266 #, fuzzy
267 #| msgid "Linux (various distributions), x86 and x86-64"
268 msgid "Linux (2.6.18 or later, various distributions), x86 and x86-64"
269 msgstr "Linux (各種ディストリビューション), x86 または x86-64"
270
271 #. type: Bullet: '* '
272 #: src/doc/tutorial.md:78
273 #, fuzzy
274 #| msgid "OSX 10.6 (\"Snow Leopard\") or greater, x86 and x86-64"
275 msgid "OSX 10.7 (Lion) or greater, x86 and x86-64"
276 msgstr "OSX 10.6 (\"Snow Leopard\") 以降, x86 または x86-64"
277
278 #. type: Plain text
279 #: src/doc/tutorial.md:81
280 msgid ""
281 "You may find that other platforms work, but these are our \"tier 1\" "
282 "supported build environments that are most likely to work."
283 msgstr ""
284 "スナップショットは他のプラットフォームでも動作するかもしれませんが、\"tier "
285 "1\" プラットフォームとしてサポートされているのは上記のみです。"
286
287 #. type: Plain text
288 #: src/doc/tutorial.md:88
289 msgid ""
290 "> *Note:* Windows users should read the detailed > \"[getting started]"
291 "[wiki-start]\" notes on the wiki. Even when using > the binary installer, "
292 "the Windows build requires a MinGW installation, > the precise details of "
293 "which are not discussed here. Finally, `rustc` may > need to be [referred to "
294 "as `rustc.exe`][bug-3319]. It's a bummer, we > know."
295 msgstr ""
296 "> *注意:* Windows ユーザーは wiki の [getting started][wiki-start] の記事"
297 "を読んでください。 本書では詳細を説明しませんが、インストーラを利用する場合で"
298 "も、MinGW のインストールなど、追加の手順が必要です。また、コンパイラは "
299 "`rustc` ではなく、 [`rustc.exe` として呼び出す必要がある][bug-3319] かもしれ"
300 "ません。このような制限があることはは、本当に残念です。"
301
302 #. type: Plain text
303 #: src/doc/tutorial.md:92
304 #, fuzzy
305 #| msgid ""
306 #| "[bug-3319]: https://github.com/mozilla/rust/issues/3319 [wiki-start]: "
307 #| "https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust"
308 msgid ""
309 "[bug-3319]: https://github.com/mozilla/rust/issues/3319 [wiki-start]: "
310 "https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust "
311 "[git]: https://github.com/mozilla/rust.git"
312 msgstr ""
313 "[bug-3319]: https://github.com/mozilla/rust/issues/3319\n"
314 "[wiki-start]: https://github.com/mozilla/rust/wiki/Note-getting-started-"
315 "developing-Rust"
316
317 #. type: Plain text
318 #: src/doc/tutorial.md:95
319 msgid ""
320 "To build from source you will also need the following prerequisite packages:"
321 msgstr "ソースからビルドするためには、以下のパッケージが必要です。"
322
323 #. type: Bullet: '* '
324 #: src/doc/tutorial.md:101
325 msgid "g++ 4.4 or clang++ 3.x"
326 msgstr "g++ 4.4 または clang++ 3.x"
327
328 #. type: Bullet: '* '
329 #: src/doc/tutorial.md:101
330 msgid "python 2.6 or later (but not 3.x)"
331 msgstr "python 2.6 以降 (ただし、 3.x は除く)"
332
333 #. type: Bullet: '* '
334 #: src/doc/tutorial.md:101
335 msgid "perl 5.0 or later"
336 msgstr "perl 5.0 以降"
337
338 #. type: Bullet: '* '
339 #: src/doc/tutorial.md:101
340 msgid "gnu make 3.81 or later"
341 msgstr "gnu make 3.81 以降"
342
343 #. type: Bullet: '* '
344 #: src/doc/tutorial.md:101
345 msgid "curl"
346 msgstr "curl"
347
348 #. type: Plain text
349 #: src/doc/tutorial.md:104
350 msgid ""
351 "If you've fulfilled those prerequisites, something along these lines should "
352 "work."
353 msgstr "上記条件を満たしていれば、以下のような手順でビルド可能なはずです。"
354
355 #. type: Plain text
356 #: src/doc/tutorial.md:112
357 #, fuzzy
358 #| msgid ""
359 #| "~~~~ {.notrust} $ curl -O http://static.rust-lang.org/dist/rust-nightly.tar."
360 #| "gz $ tar -xzf rust-nightly.tar.gz $ cd rust-nightly $ ./configure $ make && make "
361 #| "install ~~~~"
362 msgid ""
363 "~~~~ {.notrust} $ curl -O http://static.rust-lang.org/dist/rust-nightly.tar.gz $ "
364 "tar -xzf rust-nightly.tar.gz $ cd rust-nightly $ ./configure $ make && make install "
365 "~~~~"
366 msgstr ""
367 "~~~~ {.notrust}\n"
368 "$ curl -O http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
369 "$ tar -xzf rust-nightly.tar.gz $ cd rust-nightly $ ./configure\n"
370 "$ make && make install\n"
371 "~~~~"
372
373 #. type: Plain text
374 #: src/doc/tutorial.md:118
375 msgid ""
376 "You may need to use `sudo make install` if you do not normally have "
377 "permission to modify the destination directory. The install locations can be "
378 "adjusted by passing a `--prefix` argument to `configure`. Various other "
379 "options are also supported: pass `--help` for more information on them."
380 msgstr ""
381 "インストール先のディレクトリを変更する権限がない場合、 `sudo make install` を"
382 "実行する必要があるかもしれません。インストール先は `configure` に `--prefix` "
383 "引数を渡すことで変更できます。`configure` はその他いろいろなオプションをサ"
384 "ポートしています。詳細については、 `--help` 引数を指定して実行してください。"
385
386 #. type: Plain text
387 #: src/doc/tutorial.md:122
388 #, fuzzy
389 #| msgid ""
390 #| "When complete, `make install` will place several programs into `/usr/"
391 #| "local/bin`: `rustc`, the Rust compiler; `rustdoc`, the API-documentation "
392 #| "tool; and `rustpkg`, the Rust package manager."
393 msgid ""
394 "When complete, `make install` will place several programs into `/usr/local/"
395 "bin`: `rustc`, the Rust compiler, and `rustdoc`, the API-documentation tool."
396 msgstr ""
397 "ビルド完了後、`make install` を実行すると、以下のプログラムが `/usr/local/"
398 "bin` にインストールされます。\n"
399 "\n"
400 "* `rustc`: Rust のコンパイラ\n"
401 "* `rustdoc`: API ドキュメント作成ツール\n"
402 "* `rustpkg`: Rust のパッケージマネージャ\n"
403
404 #. type: Plain text
405 #: src/doc/tutorial.md:125
406 #, fuzzy
407 #| msgid ""
408 #| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
409 #| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
410 msgid ""
411 "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
412 "http://static.rust-lang.org/dist/rust-nightly-install.exe"
413 msgstr ""
414 "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
415 "[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
416
417 #. type: Plain text
418 #: src/doc/tutorial.md:127
419 msgid "## Compiling your first program"
420 msgstr "## 最初のプログラム"
421
422 #. type: Plain text
423 #: src/doc/tutorial.md:130
424 msgid ""
425 "Rust program files are, by convention, given the extension `.rs`. Say we "
426 "have a file `hello.rs` containing this program:"
427 msgstr ""
428 "Rust プログラムのファイルの拡張子は、慣例的に `.rs` とされています。以下の内"
429 "容を持つファイル、`hello.rs` が存在するとします。"
430
431 #. type: Plain text
432 #: src/doc/tutorial.md:136
433 #, fuzzy, no-wrap
434 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
435 msgid ""
436 "~~~~\n"
437 "fn main() {\n"
438 "    println!(\"hello?\");\n"
439 "}\n"
440 "~~~~\n"
441 msgstr ""
442 "~~~~ {.ignore}\n"
443 "// main.rs\n"
444 "extern crate world;\n"
445 "fn main() { println(~\"hello \" + world::explore()); }\n"
446 "~~~~"
447
448 #. type: Plain text
449 #: src/doc/tutorial.md:140
450 msgid ""
451 "If the Rust compiler was installed successfully, running `rustc hello.rs` "
452 "will produce an executable called `hello` (or `hello.exe` on Windows) which, "
453 "upon running, will likely do exactly what you expect."
454 msgstr ""
455 "Rust のコンパイラが正しくインストールされている場合、 `rustc hello.rs` を実行"
456 "することで、実行ファイル `hello` (Windows の場合 `hello.exe`) を生成すること"
457 "が可能です。このファイルを実行すれば、予想通りの出力が得られるでしょう。"
458
459 #. type: Plain text
460 #: src/doc/tutorial.md:145
461 #, fuzzy
462 #| msgid ""
463 #| "The Rust compiler tries to provide useful information when it encounters "
464 #| "an error. If you introduce an error into the program (for example, by "
465 #| "changing `println` to some nonexistent function), and then compile it, "
466 #| "you'll see an error message like this:"
467 msgid ""
468 "The Rust compiler tries to provide useful information when it encounters an "
469 "error. If you introduce an error into the program (for example, by changing "
470 "`println!` to some nonexistent macro), and then compile it, you'll see an "
471 "error message like this:"
472 msgstr ""
473 "コンパイルエラーが発生した場合、Rust コンパイラはエラー解決のための情報を出力"
474 "します。プログラム中にエラーが含まれる場合 (上記プログラムの `println` を存在"
475 "しない別の名前に変更した場合など)、コンパイル時に以下のようなエラーメッセージ"
476 "が出力されます。"
477
478 #. type: Plain text
479 #: src/doc/tutorial.md:158
480 #, fuzzy
481 #| msgid ""
482 #| "In its simplest form, a Rust program is a `.rs` file with some types and "
483 #| "functions defined in it. If it has a `main` function, it can be compiled "
484 #| "to an executable. Rust does not allow code that's not a declaration to "
485 #| "appear at the top level of the file: all statements must live inside a "
486 #| "function.  Rust programs can also be compiled as libraries, and included "
487 #| "in other programs."
488 msgid ""
489 "In its simplest form, a Rust program is a `.rs` file with some types and "
490 "functions defined in it. If it has a `main` function, it can be compiled to "
491 "an executable. Rust does not allow code that's not a declaration to appear "
492 "at the top level of the file: all statements must live inside a function.  "
493 "Rust programs can also be compiled as libraries, and included in other "
494 "programs, even ones not written in Rust."
495 msgstr ""
496 "最も単純な Rust プログラムは、いくつかの型や関数が定義された `.rs` ファイルの"
497 "みからなります。`.rs` ファイルをコンパイルして実行可能ファイルを作成する場"
498 "合、ファイル中に `main` 関数が含まれている必要があります。Rust プログラムで"
499 "ファイルのトップレベルに記述可能なのは宣言 (declaration) のみです。ステートメ"
500 "ント (statement) は、すべて関数内部に記述されます。Rust のプログラムは、他の"
501 "プログラムから利用するライブラリとしてコンパイルすることも可能です。"
502
503 #. type: Plain text
504 #: src/doc/tutorial.md:160
505 msgid "## Editing Rust code"
506 msgstr "## Rust のコードを編集する"
507
508 #. type: Plain text
509 #: src/doc/tutorial.md:170
510 msgid ""
511 "There are vim highlighting and indentation scripts in the Rust source "
512 "distribution under `src/etc/vim/`. There is an emacs mode under `src/etc/"
513 "emacs/` called `rust-mode`, but do read the instructions included in that "
514 "directory. In particular, if you are running emacs 24, then using emacs's "
515 "internal package manager to install `rust-mode` is the easiest way to keep "
516 "it up to date. There is also a package for Sublime Text 2, available both "
517 "[standalone][sublime] and through [Sublime Package Control][sublime-pkg], "
518 "and support for Kate under `src/etc/kate`."
519 msgstr ""
520 "vim のハイライトとインデント用スクリプトは、Rust のソースツリーの `src/etc/"
521 "vim` 以下にあります。emacs の Rust 編集用モードの `rust-mode` は、 `src/etc/"
522 "emacs/` 以下にありますが、当該ディレクトリに配置されているインストール手順に"
523 "従って操作する必要があります。 emacs 24 以降をご利用の場合、 emacs 組み込みの"
524 "パッケージマネージャで `rust-mode` をインストールするのが最もお手軽です。"
525 "Sublime Text 2 用のパッケージは、[スタンドアロン版][sublime] と、[Sublime "
526 "Package Control][sublime-pkg] 版の2つがあります。Kate 向けパッケージは `src/"
527 "etc/kate` 以下です。"
528
529 #. type: Plain text
530 #: src/doc/tutorial.md:177
531 msgid ""
532 "There is ctags support via `src/etc/ctags.rust`, but many other tools and "
533 "editors are not yet supported. If you end up writing a Rust mode for your "
534 "favorite editor, let us know so that we can link to it."
535 msgstr ""
536 "ctags は `src/etc/ctags.rust` を利用することで rust をサポートします。多くの"
537 "ツールやエディタは rust をサポートしていません。もしあなたがお気に入りのエ"
538 "ディタ向けのRust モードを作成した場合、リンクを貼りたいのでお知らせください。"
539
540 #. type: Plain text
541 #: src/doc/tutorial.md:180
542 msgid ""
543 "[sublime]: http://github.com/dbp/sublime-rust [sublime-pkg]: http://wbond."
544 "net/sublime_packages/package_control"
545 msgstr ""
546 "[sublime]: http://github.com/dbp/sublime-rust\n"
547 "[sublime-pkg]: http://wbond.net/sublime_packages/package_control"
548
549 #. type: Plain text
550 #: src/doc/tutorial.md:182
551 msgid "# Syntax basics"
552 msgstr "# 基本的な構文"
553
554 #. type: Plain text
555 #: src/doc/tutorial.md:190
556 msgid ""
557 "Assuming you've programmed in any C-family language (C++, Java, JavaScript, "
558 "C#, or PHP), Rust will feel familiar. Code is arranged in blocks delineated "
559 "by curly braces; there are control structures for branching and looping, "
560 "like the familiar `if` and `while`; function calls are written `myfunc(arg1, "
561 "arg2)`; operators are written the same and mostly have the same precedence "
562 "as in C; comments are again like C; module names are separated with double-"
563 "colon (`::`) as with C++."
564 msgstr ""
565 "あなたが C 系統の言語 (C++, Java, JavaScript, C# または PHP) でプログラミング"
566 "したことがあれば、Rust の構文には馴染みがあるでしょう。コードは波括弧で区切ら"
567 "れたブロックの中に配置され、分岐やループのための制御構文はお馴染みの `if` と "
568 "`while` で、関数呼び出しは `myfunc(arg1, arg2)` と書け、演算子は C のものと同"
569 "じで、優先順位もほとんど同じで、コメントもまた C と同じで、モジュール名のセパ"
570 "レータは C++ と同様 2つのコロン (`::`) です。"
571
572 #. type: Plain text
573 #: src/doc/tutorial.md:195
574 msgid ""
575 "The main surface difference to be aware of is that the condition at the head "
576 "of control structures like `if` and `while` does not require parentheses, "
577 "while their bodies *must* be wrapped in braces. Single-statement, unbraced "
578 "bodies are not allowed."
579 msgstr ""
580 "表記上の違いで注目すべき点は、`if` や `while` などの制御構造の先頭にある条件"
581 "句を丸括弧で囲う必要がない点と、ボディ部をで波括弧で **囲わなければならない"
582 "** という点です。ボディ部が単一のステートメントであっても、波括弧を省略するこ"
583 "とはできません。"
584
585 #. type: Plain text
586 #: src/doc/tutorial.md:208
587 #, no-wrap
588 msgid ""
589 "~~~~\n"
590 "# mod universe { pub fn recalibrate() -> bool { true } }\n"
591 "fn main() {\n"
592 "    /* A simple loop */\n"
593 "    loop {\n"
594 "        // A tricky calculation\n"
595 "        if universe::recalibrate() {\n"
596 "            return;\n"
597 "        }\n"
598 "    }\n"
599 "}\n"
600 "~~~~\n"
601 msgstr ""
602 "~~~~\n"
603 "# mod universe { pub fn recalibrate() -> bool { true } }\n"
604 "fn main() {\n"
605 "    /* シンプルなループ */\n"
606 "    loop {\n"
607 "        // 複雑な計算\n"
608 "        if universe::recalibrate() {\n"
609 "            return;\n"
610 "        }\n"
611 "    }\n"
612 "}\n"
613 "~~~~\n"
614
615 #. type: Plain text
616 #: src/doc/tutorial.md:212
617 msgid ""
618 "The `let` keyword introduces a local variable. Variables are immutable by "
619 "default. To introduce a local variable that you can re-assign later, use "
620 "`let mut` instead."
621 msgstr ""
622 "`let` キーワードにより、ローカル変数を定義します。変数はデフォルトでは "
623 "immutable (変更不可) です。再代入可能なローカル変数を定義するためには、`let "
624 "mut` を用います。"
625
626 #. type: Plain text
627 #: src/doc/tutorial.md:216
628 msgid "~~~~ let hi = \"hi\"; let mut count = 0;"
629 msgstr ""
630 "~~~~\n"
631 " let hi = \"hi\";\n"
632 " let mut count = 0;"
633
634 #. type: Plain text
635 #: src/doc/tutorial.md:222
636 #, fuzzy, no-wrap
637 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
638 msgid ""
639 "while count < 10 {\n"
640 "    println!(\"count is {}\", count);\n"
641 "    count += 1;\n"
642 "}\n"
643 "~~~~\n"
644 msgstr ""
645 "~~~~ {.ignore}\n"
646 "// main.rs\n"
647 "extern crate world;\n"
648 "fn main() { println(~\"hello \" + world::explore()); }\n"
649 "~~~~"
650
651 #. type: Plain text
652 #: src/doc/tutorial.md:226
653 #, fuzzy
654 #| msgid ""
655 #| "Although Rust can almost always infer the types of local variables, you "
656 #| "can specify a variable's type by following it with a colon, then the type "
657 #| "name. Static items, on the other hand, always require a type annotation."
658 msgid ""
659 "Although Rust can almost always infer the types of local variables, you can "
660 "specify a variable's type by following it in the `let` with a colon, then "
661 "the type name. Static items, on the other hand, always require a type "
662 "annotation."
663 msgstr ""
664 "Rust は、ほぼすべてのローカル変数の型を推論してくれますが、コロンの後に続けて"
665 "型名を書くことで、明示的に変数の型を指定することもできます。一方、静的な項目 "
666 "(static item) には、常に型注釈を指定しなければなりません。"
667
668 #. type: Plain text
669 #: src/doc/tutorial.md:233
670 msgid ""
671 "~~~~ static MONSTER_FACTOR: f64 = 57.8; let monster_size = MONSTER_FACTOR * "
672 "10.0; let monster_size: int = 50; ~~~~"
673 msgstr ""
674 "~~~~\n"
675 "static MONSTER_FACTOR: f64 = 57.8;\n"
676 "let monster_size = MONSTER_FACTOR * 10.0;\n"
677 "let monster_size: int = 50;\n"
678 "~~~~"
679
680 #. type: Plain text
681 #: src/doc/tutorial.md:242
682 msgid ""
683 "Local variables may shadow earlier declarations, as in the previous example: "
684 "`monster_size` was first declared as a `f64`, and then a second "
685 "`monster_size` was declared as an `int`. If you were to actually compile "
686 "this example, though, the compiler would determine that the first "
687 "`monster_size` is unused and issue a warning (because this situation is "
688 "likely to indicate a programmer error). For occasions where unused variables "
689 "are intentional, their names may be prefixed with an underscore to silence "
690 "the warning, like `let _monster_size = 50;`."
691 msgstr ""
692 "ローカル変数は、先行する宣言を隠すことがあります。先の例では、1つ目の "
693 "`monster_size` は `f64` として宣言され、2つ目の `monster_size` は `int` とし"
694 "て宣言されています。このプログラムをコンパイルした場合、「1つ目の "
695 "`monster_size` は未使用である」という警告メッセージが出力されます (プログラマ"
696 "が何らかの誤りを犯している可能性があるため)。未使用変数の存在が意図的なもので"
697 "あった場合、未使用変数名の先頭にアンダースコアをつけることで、警告を抑制でき"
698 "ます (`let _monster_size = 50;`)。"
699
700 #. type: Plain text
701 #: src/doc/tutorial.md:248
702 msgid ""
703 "Rust identifiers start with an alphabetic character or an underscore, and "
704 "after that may contain any sequence of alphabetic characters, numbers, or "
705 "underscores. The preferred style is to write function, variable, and module "
706 "names with lowercase letters, using underscores where they help readability, "
707 "while writing types in camel case."
708 msgstr ""
709 "Rust の識別子 (identifier) は、アルファベット、数字、またはアンダースコア "
710 "(`_`) から構成されますが、先頭の文字は数字以外でなければなりません。関数名、"
711 "変数名、モジュール名はスネークケース (アルファベットは小文字にし、単語間をア"
712 "ンダースコアで区切る) にし、型の名前はアッパーキャメルケースにすることが推奨"
713 "されています。"
714
715 #. type: Plain text
716 #: src/doc/tutorial.md:253
717 #, no-wrap
718 msgid ""
719 "~~~\n"
720 "let my_variable = 100;\n"
721 "type MyType = int;     // primitive types are _not_ camel case\n"
722 "~~~\n"
723 msgstr ""
724 "~~~\n"
725 "let my_variable = 100;\n"
726 "type MyType = int;     // プリミティブ型はキャメルケース __ではない__\n"
727 "~~~\n"
728
729 #. type: Plain text
730 #: src/doc/tutorial.md:255
731 msgid "## Expressions and semicolons"
732 msgstr "## 式とセミコロン"
733
734 #. type: Plain text
735 #: src/doc/tutorial.md:261
736 msgid ""
737 "Though it isn't apparent in all code, there is a fundamental difference "
738 "between Rust's syntax and predecessors like C.  Many constructs that are "
739 "statements in C are expressions in Rust, allowing code to be more concise. "
740 "For example, you might write a piece of code like this:"
741 msgstr ""
742 "コードの見た目から明らかではないのですが、Rust の構文と、C 等の先行言語の構文"
743 "との間の根本的な違いがとして、C ではステートメントとして扱われる多くの構文要"
744 "素が、Rust では式として扱われるという点があります。Rust のこの特徴により、"
745 "コードをより簡潔に書くことができるようになります。例えば、C 系言語では以下の"
746 "ようにコードを書きますが、"
747
748 #. type: Plain text
749 #: src/doc/tutorial.md:275
750 msgid "But, in Rust, you don't have to repeat the name `price`:"
751 msgstr "Rust では、変数名 `price` を繰り返し書く必要はありません。"
752
753 #. type: Plain text
754 #: src/doc/tutorial.md:293
755 msgid ""
756 "Both pieces of code are exactly equivalent: they assign a value to `price` "
757 "depending on the condition that holds. Note that there are no semicolons in "
758 "the blocks of the second snippet. This is important: the lack of a semicolon "
759 "after the last statement in a braced block gives the whole block the value "
760 "of that last expression."
761 msgstr ""
762 "どちらのコードも、全く等価です。`price` には、条件 (この場合は `item` の値) "
763 "に対応した値が代入されます。2つ目のコード例では、ブロックの中にセミコロンが書"
764 "かれていないことに注意してください。ブロック内の最後のステートメントの後にセ"
765 "ミコロンがない場合、**ブロック全体の値 (ブロックを式として評価した際の値) は"
766 "最後の式の値になります**。"
767
768 #. type: Plain text
769 #: src/doc/tutorial.md:299
770 msgid ""
771 "Put another way, the semicolon in Rust *ignores the value of an "
772 "expression*.  Thus, if the branches of the `if` had looked like `{ 4; }`, "
773 "the above example would simply assign `()` (nil or void) to `price`. But "
774 "without the semicolon, each branch has a different value, and `price` gets "
775 "the value of the branch that was taken."
776 msgstr ""
777 "言い換えると、Rust では、セミコロンにより **式の値が無視されます。** したがっ"
778 "て、上記の例で `if` のすべての節 (branch) が `{ 4; }` のように書かれていたと"
779 "したら、`price` には単に `()` (nil または void の意) が代入されます。しかし、"
780 "式にセミコロンが付けられていない場合、各節はそれぞれ異なる値を持ち、 `price` "
781 "には節のうち実行されたものの値が代入されます。"
782
783 #. type: Plain text
784 #: src/doc/tutorial.md:304
785 msgid ""
786 "In short, everything that's not a declaration (declarations are `let` for "
787 "variables; `fn` for functions; and any top-level named items such as [traits]"
788 "(#traits), [enum types](#enums), and static items) is an expression, "
789 "including function bodies."
790 msgstr ""
791 "まとめると、宣言 (変数の `let`, 関数の `fn`, [トレイト](#トレイト) や [列挙"
792 "型](#列挙型)、静的な項目などの、トップレベルで名前を持つ項目) でないものは、"
793 "すべてが式となります。関数のボディ部も式です。"
794
795 #. type: Plain text
796 #: src/doc/tutorial.md:312
797 #, no-wrap
798 msgid ""
799 "~~~~\n"
800 "fn is_four(x: int) -> bool {\n"
801 "   // No need for a return statement. The result of the expression\n"
802 "   // is used as the return value.\n"
803 "   x == 4\n"
804 "}\n"
805 "~~~~\n"
806 msgstr ""
807 "~~~~\n"
808 "fn is_four(x: int) -> bool {\n"
809 "   // return ステートメントは省略可能。最後の式の値が戻り値となる。\n"
810 "   x == 4\n"
811 "}\n"
812 "~~~~\n"
813
814 #. type: Plain text
815 #: src/doc/tutorial.md:314
816 msgid "## Primitive types and literals"
817 msgstr "## プリミティブ型とリテラル"
818
819 #. type: Plain text
820 #: src/doc/tutorial.md:321
821 msgid ""
822 "There are general signed and unsigned integer types, `int` and `uint`, as "
823 "well as 8-, 16-, 32-, and 64-bit variants, `i8`, `u16`, etc.  Integers can "
824 "be written in decimal (`144`), hexadecimal (`0x90`), octal (`0o70`), or "
825 "binary (`0b10010000`) base. Each integral type has a corresponding literal "
826 "suffix that can be used to indicate the type of a literal: `i` for `int`, "
827 "`u` for `uint`, `i8` for the `i8` type."
828 msgstr ""
829 "Rust には、他の言語と同様、符号付き整数の `int` と、符号なし整数の `uint` が"
830 "あります。同様に、8 または 16, 32, 64 ビット幅の `i8`, `u16` などもあります。"
831 "整数リテラルは、10進数 (`144`)、16進数 (`0x90`)、または2進数 (`0b10010000`) "
832 "の表記が可能です。整数リテラルの型を表すための、各整数型に対応したサフィック"
833 "スがあります。例えば、`i` は `int` 型、`u` は `uint` 型、`i8` は `i8` 型に対"
834 "応します。"
835
836 #. type: Plain text
837 #: src/doc/tutorial.md:327
838 msgid ""
839 "In the absence of an integer literal suffix, Rust will infer the integer "
840 "type based on type annotations and function signatures in the surrounding "
841 "program. In the absence of any type information at all, Rust will assume "
842 "that an unsuffixed integer literal has type `int`."
843 msgstr ""
844 "サフィックスが省略されている整数リテラルの型は、周囲にある型アノテーションや"
845 "関数のシグネチャから推論されます。型について一切情報が得られない場合、サ"
846 "フィックスなしの整数リテラルは `int` 型だとみなされます。"
847
848 #. type: Plain text
849 #: src/doc/tutorial.md:334
850 #, fuzzy, no-wrap
851 #| msgid ""
852 #| "~~~~\n"
853 #| "let a = 1;       // a is an int\n"
854 #| "let b = 10i;     // b is an int, due to the 'i' suffix\n"
855 #| "let c = 100u;    // c is a uint\n"
856 #| "let d = 1000i32; // d is an i32\n"
857 #| "~~~~\n"
858 msgid ""
859 "~~~~\n"
860 "let a = 1;       // `a` is an `int`\n"
861 "let b = 10i;     // `b` is an `int`, due to the `i` suffix\n"
862 "let c = 100u;    // `c` is a `uint`\n"
863 "let d = 1000i32; // `d` is an `i32`\n"
864 "~~~~\n"
865 msgstr ""
866 "~~~~\n"
867 "let a = 1;       // a は int\n"
868 "let b = 10i;     // b は int (サフィックス 'i' がある)\n"
869 "let c = 100u;    // c は uint\n"
870 "let d = 1000i32; // d は i32\n"
871 "~~~~\n"
872
873 #. type: Plain text
874 #: src/doc/tutorial.md:339
875 #, fuzzy
876 #| msgid ""
877 #| "There are two floating-point types: `f32`, and `f64`. Floating-point "
878 #| "numbers are written `0.0`, `1e6`, or `2.1e-4`. Like integers, floating-"
879 #| "point literals are inferred to the correct type. Suffixes `f32`, and "
880 #| "`f64` can be used to create literals of a specific type."
881 msgid ""
882 "There are two floating-point types: `f32`, and `f64`.  Floating-point "
883 "numbers are written `0.0`, `1e6`, or `2.1e-4`.  Like integers, floating-"
884 "point literals are inferred to the correct type.  Suffixes `f32`, and `f64` "
885 "can be used to create literals of a specific type."
886 msgstr ""
887 "浮動小数型は、 `f32`, `f64` の2種類があります。浮動小数リテラルは `0.0` や、 "
888 "`1e6`、 `2.1e-4` といった表記が可能です。整数と同じく、サフィックスが省略され"
889 "た浮動小数リテラルは型推論されます。浮動小数のサフィックスは `f32`、`f64` の3"
890 "種類で、リテラルの末尾につけることで、対応する型の値を作り出すことができま"
891 "す。"
892
893 #. type: Plain text
894 #: src/doc/tutorial.md:341
895 msgid "The keywords `true` and `false` produce literals of type `bool`."
896 msgstr "`true` キーワードと `false` キーワードは、`bool` 型のリテラルです。"
897
898 #. type: Plain text
899 #: src/doc/tutorial.md:348
900 #, fuzzy
901 #| msgid ""
902 #| "Characters, the `char` type, are four-byte Unicode codepoints, whose "
903 #| "literals are written between single quotes, as in `'x'`.  Just like C, "
904 #| "Rust understands a number of character escapes, using the backslash "
905 #| "character, such as `\\n`, `\\r`, and `\\t`. String literals, written "
906 #| "between double quotes, allow the same escape sequences.  More on strings "
907 #| "[later](#vectors-and-strings)."
908 msgid ""
909 "Characters, the `char` type, are four-byte Unicode codepoints, whose "
910 "literals are written between single quotes, as in `'x'`.  Just like C, Rust "
911 "understands a number of character escapes, using the backslash character, "
912 "such as `\\n`, `\\r`, and `\\t`. String literals, written between double "
913 "quotes, allow the same escape sequences, and do no other processing, unlike "
914 "languages such as PHP or shell."
915 msgstr ""
916 "文字は `char` 型で表され、4バイトの Unicode コードポイントに対応しています。"
917 "`'x'` のように、文字をシングルクオートで囲んだものが文字リテラルです。C と同"
918 "様、 Rust もバックスラッシュを使ったエスケープシーケンス (`\\n`, `\\r`, `"
919 "\\t`) に対応しています。文字列リテラル (複数の文字をダブルクオートで囲ったも"
920 "の) も同じエスケープシーケンスに対応しています。詳細は [ベクタと文字列](#ベク"
921 "タと文字列) の章で述べます。"
922
923 #. type: Plain text
924 #: src/doc/tutorial.md:356
925 msgid "The nil type, written `()`, has a single value, also written `()`."
926 msgstr ""
927 "nil 型は `()` と表記されます。 nil 型の唯一の値も `()` と表記されます。"
928
929 #. type: Plain text
930 #: src/doc/tutorial.md:358
931 msgid "## Operators"
932 msgstr "## 演算子"
933
934 #. type: Plain text
935 #: src/doc/tutorial.md:363
936 msgid ""
937 "Rust's set of operators contains very few surprises. Arithmetic is done with "
938 "`*`, `/`, `%`, `+`, and `-` (multiply, quotient, remainder, add, and "
939 "subtract). `-` is also a unary prefix operator that negates numbers. As in "
940 "C, the bitwise operators `>>`, `<<`, `&`, `|`, and `^` are also supported."
941 msgstr ""
942 "Rust の演算子には、あまり変わったものはありません。算術演算子は `*` (乗算)、 "
943 "`/` (除算), `%` (剰余), `+` (加算), `-` (減算) です。`-` は数の符号を反転する"
944 "単行演算子でもあります。C と同様、ビット演算子 `>>`, `<<`, `&`, `|`, `^` もサ"
945 "ポートされています。"
946
947 #. type: Plain text
948 #: src/doc/tutorial.md:366
949 #, fuzzy
950 #| msgid ""
951 #| "Note that, if applied to an integer value, `!` flips all the bits (like "
952 #| "`~` in C)."
953 msgid ""
954 "Note that, if applied to an integer value, `!` flips all the bits (bitwise "
955 "NOT, like `~` in C)."
956 msgstr ""
957 "整数型に対して `!` 演算子を適用すると、ビット単位での反転操作 (C の `~` と同"
958 "じ動作) が行われることに注意してください。"
959
960 #. type: Plain text
961 #: src/doc/tutorial.md:370
962 msgid ""
963 "The comparison operators are the traditional `==`, `!=`, `<`, `>`, `<=`, and "
964 "`>=`. Short-circuiting (lazy) boolean operators are written `&&` (and) and "
965 "`||` (or)."
966 msgstr ""
967 "比較演算子は、従来の言語と同じく、`==`, `!=`, `<`, `>`, `<=`, `>=` です。短絡"
968 "評価 (遅延評価) されるブール演算子は、 `&&` (and 演算) と `||` (or 演算) があ"
969 "ります。"
970
971 #. type: Plain text
972 #: src/doc/tutorial.md:377
973 #, fuzzy
974 #| msgid ""
975 #| "For type casting, Rust uses the binary `as` operator.  It takes an "
976 #| "expression on the left side and a type on the right side and will, if a "
977 #| "meaningful conversion exists, convert the result of the expression to the "
978 #| "given type."
979 msgid ""
980 "For compile-time type casting, Rust uses the binary `as` operator.  It takes "
981 "an expression on the left side and a type on the right side and will, if a "
982 "meaningful conversion exists, convert the result of the expression to the "
983 "given type. Generally, `as` is only used with the primitive numeric types or "
984 "pointers, and is not overloadable.  [`transmute`][transmute] can be used for "
985 "unsafe C-like casting of same-sized types."
986 msgstr ""
987 "Rust では、型のキャストには二項演算子 `as` を使います。`as` 演算子は、左辺に"
988 "式、右辺に型を取り、意味のある変換が可能な場合に限り、式の評価結果を指定され"
989 "た型に変換します。"
990
991 #. type: Plain text
992 #: src/doc/tutorial.md:383
993 msgid "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~"
994 msgstr ""
995 "~~~~\n"
996 "let x: f64 = 4.0;\n"
997 "let y: uint = x as uint;\n"
998 "assert!(y == 4u);\n"
999 "~~~~"
1000
1001 #. type: Plain text
1002 #: src/doc/tutorial.md:385
1003 #, fuzzy
1004 #| msgid ""
1005 #| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
1006 #| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
1007 msgid ""
1008 "[transmute]: http://static.rust-lang.org/doc/master/std/cast/fn.transmute."
1009 "html"
1010 msgstr ""
1011 "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
1012 "[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
1013
1014 #. type: Plain text
1015 #: src/doc/tutorial.md:387
1016 msgid "## Syntax extensions"
1017 msgstr "## 構文拡張"
1018
1019 #. type: Plain text
1020 #: src/doc/tutorial.md:395
1021 #, fuzzy, no-wrap
1022 #| msgid ""
1023 #| "*Syntax extensions* are special forms that are not built into the language,\n"
1024 #| "but are instead provided by the libraries. To make it clear to the reader when\n"
1025 #| "a name refers to a syntax extension, the names of all syntax extensions end\n"
1026 #| "with `!`. The standard library defines a few syntax extensions, the most\n"
1027 #| "useful of which is `fmt!`, a `sprintf`-style text formatter that you will\n"
1028 #| "often see in examples.\n"
1029 msgid ""
1030 "*Syntax extensions* are special forms that are not built into the language,\n"
1031 "but are instead provided by the libraries. To make it clear to the reader when\n"
1032 "a name refers to a syntax extension, the names of all syntax extensions end\n"
1033 "with `!`. The standard library defines a few syntax extensions, the most\n"
1034 "useful of which is [`format!`][fmt], a `sprintf`-like text formatter that you\n"
1035 "will often see in examples, and its related family of macros: `print!`,\n"
1036 "`println!`, and `write!`.\n"
1037 msgstr "**構文拡張** *(Syntax extensions)* は言語組み込みではなく、ライブラリにより提供される特殊形式 (スペシャルフォーム) です。プログラム中に構文拡張が登場したことを外見上明確にするため、構文拡張の名前には末尾に `!` をつけますなければなりません。標準ライブラリではいくつかの構文拡張が定義されていますが、その中でも最も有用なのは `fmt!` です。`fmt!` は `sprintf`スタイルの書式整形を行うもので、後のコード例の中でも何度か見かけることになるでしょう。\n"
1038
1039 #. type: Plain text
1040 #: src/doc/tutorial.md:399
1041 #, fuzzy
1042 #| msgid ""
1043 #| "`fmt!` supports most of the directives that [printf][pf] supports, but "
1044 #| "unlike printf, will give you a compile-time error when the types of the "
1045 #| "directives don't match the types of the arguments."
1046 msgid ""
1047 "`format!` draws syntax from Python, but contains many of the same principles "
1048 "that [printf][pf] has. Unlike printf, `format!` will give you a compile-time "
1049 "error when the types of the directives don't match the types of the "
1050 "arguments."
1051 msgstr ""
1052 "`fmt!` は、[`printf`][pf] がサポートするほとんどのディレクティブ (フォーマッ"
1053 "ト指定子) をサポートしますが、`printf` とは異なり、ディレクティブと引数の型が"
1054 "一致しない場合はコンパイルエラーとなります。"
1055
1056 #. type: Plain text
1057 #: src/doc/tutorial.md:402
1058 msgid "~~~~ # let mystery_object = ();"
1059 msgstr ""
1060 "~~~~\n"
1061 "# let mystery_object = ();"
1062
1063 #. type: Plain text
1064 #: src/doc/tutorial.md:409
1065 #, fuzzy
1066 #| msgid ""
1067 #| "// %? will conveniently print any type println(fmt!(\"what is this thing: "
1068 #| "%?\", mystery_object)); ~~~~"
1069 msgid ""
1070 "// `{:?}` will conveniently print any type println!(\"what is this thing: "
1071 "{:?}\", mystery_object); ~~~~"
1072 msgstr ""
1073 "// %? は任意の型を表示できる便利なディレクティブです\n"
1074 "println(fmt!(\"what is this thing: %?\", mystery_object));\n"
1075 "~~~~"
1076
1077 #. type: Plain text
1078 #: src/doc/tutorial.md:412
1079 #, fuzzy
1080 #| msgid ""
1081 #| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
1082 #| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
1083 msgid ""
1084 "[pf]: http://en.cppreference.com/w/cpp/io/c/fprintf [fmt]: http://static."
1085 "rust-lang.org/doc/master/std/fmt/index.html"
1086 msgstr ""
1087 "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
1088 "[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
1089
1090 #. type: Plain text
1091 #: src/doc/tutorial.md:416
1092 #, fuzzy
1093 #| msgid ""
1094 #| "You can define your own syntax extensions with the macro system. For "
1095 #| "details, see the [macro tutorial][macros]."
1096 msgid ""
1097 "You can define your own syntax extensions with the macro system. For "
1098 "details, see the [macro tutorial][macros]. Note that macro definition is "
1099 "currently considered an unstable feature."
1100 msgstr ""
1101 "マクロシステムを利用すれば、独自に構文拡張を定義することも可能です。詳細は "
1102 "[マクロチュートリアル][macros] を参照してください。"
1103
1104 #. type: Plain text
1105 #: src/doc/tutorial.md:418
1106 msgid "# Control structures"
1107 msgstr "# 制御構造"
1108
1109 #. type: Plain text
1110 #: src/doc/tutorial.md:420
1111 msgid "## Conditionals"
1112 msgstr "## 条件式"
1113
1114 #. type: Plain text
1115 #: src/doc/tutorial.md:424
1116 msgid ""
1117 "We've seen `if` expressions a few times already. To recap, braces are "
1118 "compulsory, an `if` can have an optional `else` clause, and multiple `if`/"
1119 "`else` constructs can be chained together:"
1120 msgstr ""
1121 "`if` 式は既に何度か登場しています。これまでの説明の要点をまとめると、波括弧は"
1122 "省略不可であり、`if` 式には省略可能な `else` 句があり、複数個の `if`/`else` "
1123 "構文は互いに連鎖できる、ということでした。"
1124
1125 #. type: Plain text
1126 #: src/doc/tutorial.md:439
1127 msgid ""
1128 "The condition given to an `if` construct *must* be of type `bool` (no "
1129 "implicit conversion happens). If the arms are blocks that have a value, this "
1130 "value must be of the same type for every arm in which control reaches the "
1131 "end of the block:"
1132 msgstr ""
1133 "`if` 構文の条件式は `bool` 型ででなければなりません (暗黙的な型変換は行われま"
1134 "せん)。同一の `if` 構文に属する arm のうち、制御がブロックの末尾まで到達し得"
1135 "るものは、すべて同じ型の値でなければなりません。"
1136
1137 #. type: Plain text
1138 #: src/doc/tutorial.md:447
1139 #, fuzzy, no-wrap
1140 #| msgid "~~~~ fn line(a: int, b: int, x: int) -> int { a * x + b } fn oops(a: int, b: int, x: int) -> ()  { a * x + b; }"
1141 msgid ""
1142 "~~~~\n"
1143 "fn signum(x: int) -> int {\n"
1144 "    if x < 0 { -1 }\n"
1145 "    else if x > 0 { 1 }\n"
1146 "    else { 0 }\n"
1147 "}\n"
1148 "~~~~\n"
1149 msgstr ""
1150 "~~~~\n"
1151 "fn line(a: int, b: int, x: int) -> int { a * x + b }\n"
1152 "fn oops(a: int, b: int, x: int) -> ()  { a * x + b; }"
1153
1154 #. type: Plain text
1155 #: src/doc/tutorial.md:449
1156 msgid "## Pattern matching"
1157 msgstr "## パターンマッチ"
1158
1159 #. type: Plain text
1160 #: src/doc/tutorial.md:455
1161 msgid ""
1162 "Rust's `match` construct is a generalized, cleaned-up version of C's "
1163 "`switch` construct. You provide it with a value and a number of *arms*, each "
1164 "labelled with a pattern, and the code compares the value against each "
1165 "pattern in order until one matches. The matching pattern executes its "
1166 "corresponding arm."
1167 msgstr ""
1168 "Rust の `match` 構文は、C の `switch` 構文を整理・一般化したものです。"
1169 "`match` 構文は、パターンマッチの対象となる値と、いくつかの、 **arm**  (**訳"
1170 "注:** 分岐条件と、条件を満たした場合に実行される式の組のこと。`match` の場合"
1171 "はパターンと式の組) から構成されます。`match` 構文では、指定された値とパター"
1172 "ンの比較をコード内で記述された順番通りに行います。比較の結果、値とパターンが"
1173 "マッチした場合、対応する式が実行されます。マッチしたパターンの後に現れるパ"
1174 "ターンとの比較は行われません。"
1175
1176 #. type: Plain text
1177 #: src/doc/tutorial.md:469
1178 msgid ""
1179 "Unlike in C, there is no \"falling through\" between arms: only one arm "
1180 "executes, and it doesn't have to explicitly `break` out of the construct "
1181 "when it is finished."
1182 msgstr ""
1183 "C とは異なり、Rust では arm 間での「フォールスルー」はないため、1つの arm の"
1184 "みが実行されます。 そのため、 `match` 構文から抜ける箇所を `break` により明示"
1185 "する必要はありません。"
1186
1187 #. type: Plain text
1188 #: src/doc/tutorial.md:478
1189 #, fuzzy
1190 #| msgid ""
1191 #| "A `match` arm consists of a *pattern*, then an arrow `=>`, followed by an "
1192 #| "*action* (expression). Literals are valid patterns and match only their "
1193 #| "own value. A single arm may match multiple different patterns by "
1194 #| "combining them with the pipe operator (`|`), so long as every pattern "
1195 #| "binds the same set of variables. Ranges of numeric literal patterns can "
1196 #| "be expressed with two dots, as in `M..N`. The underscore (`_`) is a "
1197 #| "wildcard pattern that matches any single value. The asterisk (`*`)  is a "
1198 #| "different wildcard that can match one or more fields in an `enum` variant."
1199 msgid ""
1200 "A `match` arm consists of a *pattern*, then an arrow `=>`, followed by an "
1201 "*action* (expression). Literals are valid patterns and match only their own "
1202 "value. A single arm may match multiple different patterns by combining them "
1203 "with the pipe operator (`|`), so long as every pattern binds the same set of "
1204 "variables. Ranges of numeric literal patterns can be expressed with two "
1205 "dots, as in `M..N`. The underscore (`_`) is a wildcard pattern that matches "
1206 "any single value. (`..`) is a different wildcard that can match one or more "
1207 "fields in an `enum` variant."
1208 msgstr ""
1209 "`match` の arm は、 **パターン** および矢印 `=>` と、それらに続く **アクショ"
1210 "ン** (式) から構成されます。リテラルはパターンとして利用可能で、リテラル自身"
1211 "の値のみとマッチするパターンを意味します。複数のパターンをパイプ演算子 (`|`) "
1212 "で結合させることで、複数の異なるパターンにマッチする単一の arm を作ることがで"
1213 "きます。ただし、変数の束縛を行うパターンをパイプ演算子で結合する場合は、すべ"
1214 "てのパータンで束縛する変数の名前・数が一致している必要があります (**訳注:** "
1215 "変数の束縛については、本節の後半で説明します)。指定した範囲に含まれる任意の数"
1216 "値にマッチするパターンは、2つのドットで `M..N` のように表記します。アンダース"
1217 "コア (`_`) は任意の値1つにマッチするワイルドカードパターンです。アスタリスク "
1218 "(`*`) は任意の値をもつ、`enum` バリアントの複数のフィールドにマッチする、ワイ"
1219 "ルドカードです (**訳注** `enum` については、[列挙型](#列挙型) の節で説明しま"
1220 "す)。"
1221
1222 #. type: Plain text
1223 #: src/doc/tutorial.md:483
1224 msgid ""
1225 "The patterns in a match arm are followed by a fat arrow, `=>`, then an "
1226 "expression to evaluate. Each case is separated by commas. It's often "
1227 "convenient to use a block expression for each case, in which case the commas "
1228 "are optional."
1229 msgstr ""
1230 "`match` の各 arm はカンマ (`,`) は区切ります。 arm のアクションとしてブロック"
1231 "を記述することも可能で、その場合は arm 末尾のカンマを省略することが可能です。"
1232
1233 #. type: Plain text
1234 #: src/doc/tutorial.md:496
1235 msgid ""
1236 "`match` constructs must be *exhaustive*: they must have an arm covering "
1237 "every possible case. For example, the typechecker would reject the previous "
1238 "example if the arm with the wildcard pattern was omitted."
1239 msgstr ""
1240 "`match` 構文は **網羅的** でなければなりません。すなわち、`match` 対象の値と"
1241 "同じ型を持つ任意の値に対し、少なくとも 1 つ以上のパターンがマッチするだけの "
1242 "arm を含んでいなければなりません。例えば、上記コード例のワイルドカードパター"
1243 "ンの arm を削除した場合、型検査によりコンパイルエラーとされます。"
1244
1245 #. type: Plain text
1246 #: src/doc/tutorial.md:500
1247 msgid ""
1248 "A powerful application of pattern matching is *destructuring*: matching in "
1249 "order to bind names to the contents of data types."
1250 msgstr ""
1251 "パターンマッチの応用として、 **destructuring** という強力な機能があります。構"
1252 "造化代入とは、データ型内部の値を名前に束縛 (bind) することです。"
1253
1254 #. type: Plain text
1255 #: src/doc/tutorial.md:504
1256 msgid ""
1257 "> *Note:* The following code makes use of tuples (`(f64, f64)`) which > "
1258 "are explained in section 5.3. For now you can think of tuples as a list of > "
1259 "items."
1260 msgstr ""
1261 "> *注意:* 以下のコード例では5.3 節で説明されるタプル (`(f64, f64)`) を"
1262 "使っています。現時点では、タプルは項目のリストのようなものだとみなしてくださ"
1263 "い。"
1264
1265 #. type: Plain text
1266 #: src/doc/tutorial.md:525
1267 #, fuzzy
1268 #| msgid ""
1269 #| "A variable name in a pattern matches any value, *and* binds that name to "
1270 #| "the value of the matched value inside of the arm's action. Thus, `(0f, "
1271 #| "y)` matches any tuple whose first element is zero, and binds `y` to the "
1272 #| "second element. `(x, y)` matches any two-element tuple, and binds both "
1273 #| "elements to variables."
1274 msgid ""
1275 "A variable name in a pattern matches any value, *and* binds that name to the "
1276 "value of the matched value inside of the arm's action. Thus, `(0.0, y)` "
1277 "matches any tuple whose first element is zero, and binds `y` to the second "
1278 "element. `(x, y)` matches any two-element tuple, and binds both elements to "
1279 "variables.  A subpattern can also be bound to a variable, using `variable @ "
1280 "pattern`. For example:"
1281 msgstr ""
1282 "パターン内に登場する変数は、任意の値にマッチ **するだけでなく**、arm のアク"
1283 "ション内ではマッチした値が変数の名前に束縛されます。従って、 `(0f, y)` は1つ"
1284 "目の要素が 0 である任意のタプルにマッチし、 `y` には2つ目の要素の値が束縛され"
1285 "ます。`(x, y)` は任意の2要素のタプルにマッチし、タプルの各要素がそれぞれの変"
1286 "数に束縛されます。"
1287
1288 #. type: Plain text
1289 #: src/doc/tutorial.md:540
1290 msgid ""
1291 "Any `match` arm can have a guard clause (written `if EXPR`), called a "
1292 "*pattern guard*, which is an expression of type `bool` that determines, "
1293 "after the pattern is found to match, whether the arm is taken or not. The "
1294 "variables bound by the pattern are in scope in this guard expression. The "
1295 "first arm in the `angle` example shows an example of a pattern guard."
1296 msgstr ""
1297 "`match` の任意の arm は **パターンガード** と呼ばれる、ガード節 (`if EXPR` と"
1298 "書かれる) を持つことができます。パターンガードは、 `bool` 型の値をもつ式で、"
1299 "値にマッチするパターンが見つかった後に評価され、arm が実行されるかどうかを決"
1300 "定します。パターンにより束縛される変数は、ガード式からも参照可能 (ガード式の"
1301 "スコープに含まれる) です。`angle` 関数の例の最初の arm に、パターンガードの使"
1302 "用例が示されています。"
1303
1304 #. type: Plain text
1305 #: src/doc/tutorial.md:545
1306 msgid ""
1307 "You've already seen simple `let` bindings, but `let` is a little fancier "
1308 "than you've been led to believe. It, too, supports destructuring patterns. "
1309 "For example, you can write this to extract the fields from a tuple, "
1310 "introducing two variables at once: `a` and `b`."
1311 msgstr ""
1312 "`let` は単純な変数束縛だけではなく、パターンによる destructuring をサポートし"
1313 "ています。例えば、タプルからフィールドを抽出し、1度に2つの変数 `a` と `b` を"
1314 "定義することが可能です。"
1315
1316 #. type: Plain text
1317 #: src/doc/tutorial.md:550
1318 msgid ""
1319 "~~~~ # fn get_tuple_of_two_ints() -> (int, int) { (1, 1) } let (a, b) = "
1320 "get_tuple_of_two_ints(); ~~~~"
1321 msgstr ""
1322 "~~~~\n"
1323 "# fn get_tuple_of_two_ints() -> (int, int) { (1, 1) }\n"
1324 "let (a, b) = get_tuple_of_two_ints();\n"
1325 "~~~~"
1326
1327 #. type: Plain text
1328 #: src/doc/tutorial.md:554
1329 msgid ""
1330 "Let bindings only work with _irrefutable_ patterns: that is, patterns that "
1331 "can never fail to match. This excludes `let` from matching literals and most "
1332 "`enum` variants."
1333 msgstr ""
1334 "let による変数定義が可能なのは、パターンが __不可反駁__ (iefutable; 必ず値に"
1335 "マッチする) な場合のみです。この制限により、`let` を用いた destructuring で、"
1336 "リテラルやほとんどの `enum` バリアントをパターンとして用いることはできませ"
1337 "ん。"
1338
1339 #. type: Plain text
1340 #: src/doc/tutorial.md:556
1341 msgid "## Loops"
1342 msgstr "## ループ"
1343
1344 #. type: Plain text
1345 #: src/doc/tutorial.md:561
1346 #, fuzzy
1347 #| msgid ""
1348 #| "`while` denotes a loop that iterates as long as its given condition "
1349 #| "(which must have type `bool`) evaluates to `true`. Inside a loop, the "
1350 #| "keyword `break` aborts the loop, and `loop` aborts the current iteration "
1351 #| "and continues with the next."
1352 msgid ""
1353 "`while` denotes a loop that iterates as long as its given condition (which "
1354 "must have type `bool`) evaluates to `true`. Inside a loop, the keyword "
1355 "`break` aborts the loop, and `continue` aborts the current iteration and "
1356 "continues with the next."
1357 msgstr ""
1358 "`while` は、与えられた条件 (`bool` 型の値でなければならない) が `true` と評価"
1359 "されている間、繰り返し実行されるループを表します。`break` キーワードは、ルー"
1360 "プの実行を中断させます。`loop` キーワードは、現在実行中の繰り返し (イテレー"
1361 "ション) を中断し、次の繰り返しを実行します。"
1362
1363 #. type: Plain text
1364 #: src/doc/tutorial.md:570
1365 msgid ""
1366 "`loop` denotes an infinite loop, and is the preferred way of writing `while "
1367 "true`:"
1368 msgstr ""
1369 "`loop` は無限ループを表します。 `while true` と書く代わりに `loop` と書くこと"
1370 "が推奨されています。"
1371
1372 #. type: Plain text
1373 #: src/doc/tutorial.md:582
1374 msgid ""
1375 "This code prints out a weird sequence of numbers and stops as soon as it "
1376 "finds one that can be divided by five."
1377 msgstr "このコードは 5 で割り切れる数値が現れるまで、数値を出力し続けます。"
1378
1379 #. type: Plain text
1380 #: src/doc/tutorial.md:584
1381 msgid "# Data structures"
1382 msgstr "# データ構造"
1383
1384 #. type: Plain text
1385 #: src/doc/tutorial.md:586
1386 msgid "## Structs"
1387 msgstr "## 構造体"
1388
1389 #. type: Plain text
1390 #: src/doc/tutorial.md:591
1391 msgid ""
1392 "Rust struct types must be declared before they are used using the `struct` "
1393 "syntax: `struct Name { field1: T1, field2: T2 [, ...] }`, where `T1`, "
1394 "`T2`, ... denote types. To construct a struct, use the same syntax, but "
1395 "leave off the `struct`: for example: `Point { x: 1.0, y: 2.0 }`."
1396 msgstr ""
1397 "Rust の構造体 (struct) 型を利用するためには、`struct Name { field1: T1, "
1398 "field2: T2 [, ...] }` (`T1`, `T2`, .. は型を意味する) のように、 `struct` 構"
1399 "文を使った型の宣言が必要です。構造体型の値は、`Point { x: 1.0, y: 2.0 }` のよ"
1400 "うに、構造体宣言から `struct` を取り除いたものと同じ構文で作成します。"
1401
1402 #. type: Plain text
1403 #: src/doc/tutorial.md:595
1404 msgid ""
1405 "Structs are quite similar to C structs and are even laid out the same way in "
1406 "memory (so you can read from a Rust struct in C, and vice-versa). Use the "
1407 "dot operator to access struct fields, as in `mypoint.x`."
1408 msgstr ""
1409 "Rust の構造体は C の構造体とよく似ており、メモリ上のレイアウトも C と同じで"
1410 "す (そのため、Rust と C で相互に構造体を読み込むことが可能です)。構造体の"
1411 "フィールドにアクセスするには、 `mypoint.x` のように、ドット演算子を用います。"
1412
1413 #. type: Plain text
1414 #: src/doc/tutorial.md:602
1415 #, fuzzy, no-wrap
1416 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
1417 msgid ""
1418 "~~~~\n"
1419 "struct Point {\n"
1420 "    x: f64,\n"
1421 "    y: f64\n"
1422 "}\n"
1423 "~~~~\n"
1424 msgstr ""
1425 "~~~~ {.ignore}\n"
1426 "// main.rs\n"
1427 "extern crate world;\n"
1428 "fn main() { println(~\"hello \" + world::explore()); }\n"
1429 "~~~~"
1430
1431 #. type: Plain text
1432 #: src/doc/tutorial.md:605
1433 #, fuzzy
1434 #| msgid ""
1435 #| "Inherited mutability means that any field of a struct may be mutable, if "
1436 #| "the struct is in a mutable slot (or a field of a struct in a mutable "
1437 #| "slot, and so forth)."
1438 msgid ""
1439 "Structs have \"inherited mutability\", which means that any field of a "
1440 "struct may be mutable, if the struct is in a mutable slot."
1441 msgstr ""
1442 "継承ミュータビリティ (inherited mutability) とは、構造体自体がミュータブルな"
1443 "スロットに配置されている場合、構造体のすべてのフィールドもミュータブルになる"
1444 "という性質を意味する言葉です (ミュータブルなスロットに配置された構造体の"
1445 "フィールドに配置された構造体のフィールドもまた、ミュータブルになります) 。"
1446
1447 #. type: Plain text
1448 #: src/doc/tutorial.md:609
1449 msgid ""
1450 "With a value (say, `mypoint`) of such a type in a mutable location, you can "
1451 "do `mypoint.y += 1.0`. But in an immutable location, such an assignment to a "
1452 "struct without inherited mutability would result in a type error."
1453 msgstr ""
1454 "ある構造体の値 (仮に `mypoint` とします) がミュータブルな場所に配置された場"
1455 "合、 `mypoint.y += 1.0` というような操作を行うことができます。しかし、構造体"
1456 "がイミュータブルな場所に配置された場合、ミュータビリティは継承されないため、"
1457 "このような代入操作は型エラーとなります。"
1458
1459 #. type: Plain text
1460 #: src/doc/tutorial.md:614
1461 msgid ""
1462 "~~~~ {.ignore} # struct Point { x: f64, y: f64 } let mut mypoint = Point "
1463 "{ x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
1464 msgstr ""
1465 "~~~~ {.ignore}\n"
1466 "# struct Point { x: f64, y: f64 }\n"
1467 "let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
1468 "let origin = Point { x: 0.0, y: 0.0 };"
1469
1470 #. type: Plain text
1471 #: src/doc/tutorial.md:618
1472 #, fuzzy
1473 #| msgid ""
1474 #| "mypoint.y += 1.0; // mypoint is mutable, and its fields as well origin.y "
1475 #| "+= 1.0; // ERROR: assigning to immutable field ~~~~"
1476 msgid ""
1477 "mypoint.y += 1.0; // `mypoint` is mutable, and its fields as well origin.y "
1478 "+= 1.0; // ERROR: assigning to immutable field ~~~~"
1479 msgstr ""
1480 "mypoint.y += 1.0;\n"
1481 "// mypoint はミュータブル\n"
1482 "origin.y += 1.0; // ERROR: assigning to immutable field\n"
1483 "~~~~"
1484
1485 #. type: Plain text
1486 #: src/doc/tutorial.md:621
1487 msgid ""
1488 "`match` patterns destructure structs. The basic syntax is `Name { fieldname: "
1489 "pattern, ... }`:"
1490 msgstr ""
1491 "`match` のパターンで構造体の destructuring を行うことも可能です。パターン"
1492 "は、 `Name { fieldname: pattern, ... }` という構文を持ちます。"
1493
1494 #. type: Plain text
1495 #: src/doc/tutorial.md:630
1496 #, fuzzy, no-wrap
1497 #| msgid "~~~ # struct Point { x: f64, y: f64 } let point = &@~Point { x: 10f, y: 20f }; println(fmt!(\"%f\", point.x)); ~~~"
1498 msgid ""
1499 "~~~~\n"
1500 "# struct Point { x: f64, y: f64 }\n"
1501 "# let mypoint = Point { x: 0.0, y: 0.0 };\n"
1502 "match mypoint {\n"
1503 "    Point { x: 0.0, y: yy } => println!(\"{}\", yy),\n"
1504 "    Point { x: xx,  y: yy } => println!(\"{} {}\", xx, yy),\n"
1505 "}\n"
1506 "~~~~\n"
1507 msgstr ""
1508 "~~~\n"
1509 "# struct Point { x: f64, y: f64 }\n"
1510 "let point = &@~Point { x: 10f, y: 20f };\n"
1511 "println(fmt!(\"%f\", point.x));\n"
1512 "~~~"
1513
1514 #. type: Plain text
1515 #: src/doc/tutorial.md:637
1516 #, fuzzy
1517 #| msgid ""
1518 #| "In general, the field names of a struct do not have to appear in the same "
1519 #| "order they appear in the type. When you are not interested in all the "
1520 #| "fields of a struct, a struct pattern may end with `, _` (as in `Name "
1521 #| "{ field1, _ }`) to indicate that you're ignoring all other fields.  "
1522 #| "Additionally, struct fields have a shorthand matching form that simply "
1523 #| "reuses the field name as the binding name."
1524 msgid ""
1525 "In general, the field names of a struct do not have to appear in the same "
1526 "order they appear in the type. When you are not interested in all the fields "
1527 "of a struct, a struct pattern may end with `, ..` (as in `Name { field1, .. }"
1528 "`) to indicate that you're ignoring all other fields.  Additionally, struct "
1529 "fields have a shorthand matching form that simply reuses the field name as "
1530 "the binding name."
1531 msgstr ""
1532 "構造体のフィールド名の並び順は、型定義での並び順と同じにする必要はありませ"
1533 "ん。構造体のパターンマッチで、すべてのフィールドについて考える必要がない場合"
1534 "は、`Name { field1, _ }` のように、末尾に `, _` をつけることで、他のすべての"
1535 "フィールドを無視することができます。"
1536
1537 #. type: Plain text
1538 #: src/doc/tutorial.md:645
1539 #, fuzzy, no-wrap
1540 #| msgid "~~~ # struct Point { x: f64, y: f64 } let point = &@~Point { x: 10f, y: 20f }; println(fmt!(\"%f\", point.x)); ~~~"
1541 msgid ""
1542 "~~~\n"
1543 "# struct Point { x: f64, y: f64 }\n"
1544 "# let mypoint = Point { x: 0.0, y: 0.0 };\n"
1545 "match mypoint {\n"
1546 "    Point { x, .. } => println!(\"{}\", x),\n"
1547 "}\n"
1548 "~~~\n"
1549 msgstr ""
1550 "~~~\n"
1551 "# struct Point { x: f64, y: f64 }\n"
1552 "let point = &@~Point { x: 10f, y: 20f };\n"
1553 "println(fmt!(\"%f\", point.x));\n"
1554 "~~~"
1555
1556 #. type: Plain text
1557 #: src/doc/tutorial.md:647
1558 msgid "## Enums"
1559 msgstr "## 列挙型"
1560
1561 #. type: Plain text
1562 #: src/doc/tutorial.md:650
1563 #, fuzzy
1564 #| msgid ""
1565 #| "Enums are datatypes that have several alternate representations. For "
1566 #| "example, consider the type shown earlier:"
1567 msgid ""
1568 "Enums are datatypes that have several alternate representations. For "
1569 "example, consider the following type:"
1570 msgstr ""
1571 "列挙型 (enum) は、いくつかの代替表現を持つデータ型です。例えば、以下の型につ"
1572 "いて考えます。"
1573
1574 #. type: Plain text
1575 #: src/doc/tutorial.md:664
1576 #, fuzzy
1577 #| msgid ""
1578 #| "A value of this type is either a `Circle`, in which case it contains a "
1579 #| "`Point` struct and a `f64`, or a `Rectangle`, in which case it contains "
1580 #| "two `Point` structs. The run-time representation of such a value includes "
1581 #| "an identifier of the actual form that it holds, much like the \"tagged "
1582 #| "union\" pattern in C, but with better static guarantees."
1583 msgid ""
1584 "A value of this type is either a `Circle`, in which case it contains a "
1585 "`Point` struct and a f64, or a `Rectangle`, in which case it contains two "
1586 "`Point` structs. The run-time representation of such a value includes an "
1587 "identifier of the actual form that it holds, much like the \"tagged union\" "
1588 "pattern in C, but with better static guarantees."
1589 msgstr ""
1590 "この型の値は、`Point` 構造体と `f64` を含む `Circle` か、2つの `Point` 構造体"
1591 "を含む `Rectangle` のどちらかになります。列挙型の値の実行時表現には、値がどの"
1592 "形式をとっているのか示す識別子が含まれます。この表現方法は C の \"タグ付き共"
1593 "用体\" と非常によく似ていますが、Rust の列挙型はコンパイラにより値の正当性が"
1594 "静的に保証されるという点でより良いものとなっています。"
1595
1596 #. type: Plain text
1597 #: src/doc/tutorial.md:670
1598 #, fuzzy
1599 #| msgid ""
1600 #| "The above declaration will define a type `Shape` that can refer to such "
1601 #| "shapes, and two functions, `Circle` and `Rectangle`, which can be used to "
1602 #| "construct values of the type (taking arguments of the specified types). "
1603 #| "So `Circle(Point { x: 0f, y: 0f }, 10f)` is the way to create a new "
1604 #| "circle."
1605 msgid ""
1606 "The above declaration will define a type `Shape` that can refer to such "
1607 "shapes, and two functions, `Circle` and `Rectangle`, which can be used to "
1608 "construct values of the type (taking arguments of the specified types). So "
1609 "`Circle(Point { x: 0.0, y: 0.0 }, 10.0)` is the way to create a new circle."
1610 msgstr ""
1611 "上記の宣言は `Shape` 型と `Circle` と `Rectangle` という2つの関数も同時に定義"
1612 "します。これらの関数により、関数名に対応した `Shape` 型の値を構築することがで"
1613 "きます (引数の型も列挙型宣言時に指定されたものをとります)。例えば、"
1614 "`Circle(Point { x: 0f, y: 0f }, 10f)` という記述により、新しい circle を作る"
1615 "ことができます。"
1616
1617 #. type: Plain text
1618 #: src/doc/tutorial.md:673
1619 msgid ""
1620 "Enum variants need not have parameters. This `enum` declaration, for "
1621 "example, is equivalent to a C enum:"
1622 msgstr ""
1623 "列挙型のバリアントはパラメータを省略することもできます。以下の例の `enum` 宣"
1624 "言は C の列挙型と等価です。"
1625
1626 #. type: Plain text
1627 #: src/doc/tutorial.md:685
1628 msgid ""
1629 "This declaration defines `North`, `East`, `South`, and `West` as constants, "
1630 "all of which have type `Direction`."
1631 msgstr ""
1632 "この宣言は `Direction` 型の定数 `North`, `East`, `South`, `West` を定義しま"
1633 "す。"
1634
1635 #. type: Plain text
1636 #: src/doc/tutorial.md:689
1637 msgid ""
1638 "When an enum is C-like (that is, when none of the variants have parameters), "
1639 "it is possible to explicitly set the discriminator values to a constant "
1640 "value:"
1641 msgstr ""
1642 "列挙型が Cライクな (すべてのバリアントがパラメータを持たない) 場合、各定数の"
1643 "識別値 (discriminator value) を明示的に指定することも可能です。"
1644
1645 #. type: Plain text
1646 #: src/doc/tutorial.md:702
1647 msgid ""
1648 "If an explicit discriminator is not specified for a variant, the value "
1649 "defaults to the value of the previous variant plus one. If the first variant "
1650 "does not have a discriminator, it defaults to 0. For example, the value of "
1651 "`North` is 0, `East` is 1, `South` is 2, and `West` is 3."
1652 msgstr ""
1653 "バリアントの識別値が明に指定されていない場合、1つ前のバリアントの値に1を足し"
1654 "たものが設定されます。また、最初のバリアントの場合は0が設定されます。上記の例"
1655 "で言うと、 `North` は 0、 `East` は 1、 `South` は 2、`West` は3となります。"
1656
1657 #. type: Plain text
1658 #: src/doc/tutorial.md:705
1659 msgid ""
1660 "When an enum is C-like, you can apply the `as` cast operator to convert it "
1661 "to its discriminator value as an `int`."
1662 msgstr ""
1663 "C ライクな列挙型の値は、キャスト演算子 `as` を適用することで、`int` 型の識別"
1664 "値へ変換することができます。"
1665
1666 #. type: Plain text
1667 #: src/doc/tutorial.md:709
1668 msgid ""
1669 "For enum types with multiple variants, destructuring is the only way to get "
1670 "at their contents. All variant constructors can be used as patterns, as in "
1671 "this definition of `area`:"
1672 msgstr ""
1673 "複数のバリアントを持つ列挙型で、列挙型値の内部のデータを取得するには、 "
1674 "destructuring を使う必要があります。以下の `area` 関数の例のように、バリアン"
1675 "トのコンストラクタは、パターンとして用いることもできます。"
1676
1677 #. type: Plain text
1678 #: src/doc/tutorial.md:726
1679 #, fuzzy
1680 #| msgid ""
1681 #| "You can write a lone `_` to ignore an individual field, and can ignore "
1682 #| "all fields of a variant like: `Circle(*)`. As in their introduction form, "
1683 #| "nullary enum patterns are written without parentheses."
1684 msgid ""
1685 "You can write a lone `_` to ignore an individual field, and can ignore all "
1686 "fields of a variant like: `Circle(..)`. As in their introduction form, "
1687 "nullary enum patterns are written without parentheses."
1688 msgstr ""
1689 "パターンマッチの際に、特定のフィールドに対するマッチングが不要な場合、無視し"
1690 "たいフィールドの場所に `_` を書くことで、個々のフィールドを無視することができ"
1691 "ます。また、 `Circle(*)` のように書くことで、すべてのフィールドを無視すること"
1692 "も可能です。引数をとらない列挙型のパターンは、定義時の形式と同様、丸括弧の無"
1693 "い形式で記述します。"
1694
1695 #. type: Plain text
1696 #: src/doc/tutorial.md:741
1697 msgid "Enum variants may also be structs. For example:"
1698 msgstr "以下の例のように、列挙型バリアントを構造体にすることも可能です。"
1699
1700 #. type: Plain text
1701 #: src/doc/tutorial.md:765
1702 msgid "## Tuples"
1703 msgstr "## タプル"
1704
1705 #. type: Plain text
1706 #: src/doc/tutorial.md:770
1707 #, fuzzy
1708 #| msgid ""
1709 #| "Tuples in Rust behave exactly like structs, except that their fields do "
1710 #| "not have names. Thus, you cannot access their fields with dot notation.  "
1711 #| "Tuples can have any arity except for 0 (though you may consider unit, "
1712 #| "`()`, as the empty tuple if you like)."
1713 msgid ""
1714 "Tuples in Rust behave exactly like structs, except that their fields do not "
1715 "have names. Thus, you cannot access their fields with dot notation.  Tuples "
1716 "can have any arity (number of elements) except for 0 (though you may "
1717 "consider unit, `()`, as the empty tuple if you like)."
1718 msgstr ""
1719 "Rust のタプルは、フィールドが名前を持たないという点以外は、構造体と同じように"
1720 "振る舞います。フィールド名が存在しないため、ドット記法を使ってタプルのフィー"
1721 "ルドにアクセスすることはできません。タプルは 1 個以上の要素を持つことができま"
1722 "す (必要ならば、ユニット型 `()` を 0 要素のタプルと見なすことはできます。)"
1723
1724 #. type: Plain text
1725 #: src/doc/tutorial.md:777
1726 #, fuzzy, no-wrap
1727 #| msgid ""
1728 #| "For example:\n"
1729 #| "~~~~\n"
1730 #| "struct MyTup(int, int, f64);\n"
1731 #| "let mytup: MyTup = MyTup(10, 20, 30.0);\n"
1732 #| "match mytup {\n"
1733 #| "  MyTup(a, b, c) => info!(a + b + (c as int))\n"
1734 #| "}\n"
1735 #| "~~~~\n"
1736 msgid ""
1737 "~~~~\n"
1738 "let mytup: (int, int, f64) = (10, 20, 30.0);\n"
1739 "match mytup {\n"
1740 "  (a, b, c) => info!(\"{}\", a + b + (c as int))\n"
1741 "}\n"
1742 "~~~~\n"
1743 msgstr ""
1744 "~~~~\n"
1745 "struct MyTup(int, int, f64);\n"
1746 "let mytup: MyTup = MyTup(10, 20, 30.0);\n"
1747 "match mytup {\n"
1748 "  MyTup(a, b, c) => info!(a + b + (c as int))\n"
1749 "}\n"
1750 "~~~~\n"
1751
1752 #. type: Plain text
1753 #: src/doc/tutorial.md:779
1754 msgid "## Tuple structs"
1755 msgstr "## タプル構造体"
1756
1757 #. type: Plain text
1758 #: src/doc/tutorial.md:784
1759 msgid ""
1760 "Rust also has _tuple structs_, which behave like both structs and tuples, "
1761 "except that, unlike tuples, tuple structs have names (so `Foo(1, 2)` has a "
1762 "different type from `Bar(1, 2)`), and tuple structs' _fields_ do not have "
1763 "names."
1764 msgstr ""
1765 "Rust には __タプル構造体__ と呼ばれる、構造体とタプルの両者の特徴を併せ持つも"
1766 "のが存在します。タプルと異なり、タプル構造体自体は名前を持ちます (従って、"
1767 "`Foo(1, 2)` と `Bar(1, 2)` は異なる型になります。) しかし、タプル構造体の __"
1768 "フィールド__ は名前を持ちません。"
1769
1770 #. type: Plain text
1771 #: src/doc/tutorial.md:794
1772 #, fuzzy, no-wrap
1773 #| msgid ""
1774 #| "For example:\n"
1775 #| "~~~~\n"
1776 #| "struct MyTup(int, int, f64);\n"
1777 #| "let mytup: MyTup = MyTup(10, 20, 30.0);\n"
1778 #| "match mytup {\n"
1779 #| "  MyTup(a, b, c) => info!(a + b + (c as int))\n"
1780 #| "}\n"
1781 #| "~~~~\n"
1782 msgid ""
1783 "~~~~\n"
1784 "struct MyTup(int, int, f64);\n"
1785 "let mytup: MyTup = MyTup(10, 20, 30.0);\n"
1786 "match mytup {\n"
1787 "  MyTup(a, b, c) => info!(\"{}\", a + b + (c as int))\n"
1788 "}\n"
1789 "~~~~\n"
1790 msgstr ""
1791 "~~~~\n"
1792 "struct MyTup(int, int, f64);\n"
1793 "let mytup: MyTup = MyTup(10, 20, 30.0);\n"
1794 "match mytup {\n"
1795 "  MyTup(a, b, c) => info!(a + b + (c as int))\n"
1796 "}\n"
1797 "~~~~\n"
1798
1799 #. type: Plain text
1800 #: src/doc/tutorial.md:801
1801 msgid ""
1802 "There is a special case for tuple structs with a single field, which are "
1803 "sometimes called \"newtypes\" (after Haskell's \"newtype\" feature). These "
1804 "are used to define new types in such a way that the new name is not just a "
1805 "synonym for an existing type but is rather its own distinct type."
1806 msgstr ""
1807 "タプル構造体がフィールドを 1 つしか持たない場合、 \"newtype\" と呼ばれること"
1808 "があります (Haskell の \"newtype\" 機能に由来しています)。 このようなタプル構"
1809 "造体を使うことで、既存の型の別名 (シノニム) となる新しい型を定義することがで"
1810 "きます。この新しい型は、元にした型とは異なった型として扱われます。"
1811
1812 #. type: Plain text
1813 #: src/doc/tutorial.md:805
1814 msgid "~~~~ struct GizmoId(int); ~~~~"
1815 msgstr ""
1816 "~~~~\n"
1817 "struct GizmoId(int);\n"
1818 "~~~~"
1819
1820 #. type: Plain text
1821 #: src/doc/tutorial.md:808
1822 #, fuzzy
1823 #| msgid ""
1824 #| "Types like this can be useful to differentiate between data that have the "
1825 #| "same type but must be used in different ways."
1826 msgid ""
1827 "Types like this can be useful to differentiate between data that have the "
1828 "same underlying type but must be used in different ways."
1829 msgstr ""
1830 "このような型は、型は同一でも、それぞれ全く異なる扱い方をしなければならない"
1831 "データを扱う場合に用いると便利です。"
1832
1833 #. type: Plain text
1834 #: src/doc/tutorial.md:813
1835 msgid "~~~~ struct Inches(int); struct Centimeters(int); ~~~~"
1836 msgstr ""
1837 "~~~~\n"
1838 "struct Inches(int);\n"
1839 "struct Centimeters(int);\n"
1840 "~~~~"
1841
1842 #. type: Plain text
1843 #: src/doc/tutorial.md:817
1844 #, fuzzy
1845 #| msgid ""
1846 #| "The above definitions allow for a simple way for programs to avoid "
1847 #| "confusing numbers that correspond to different units."
1848 msgid ""
1849 "The above definitions allow for a simple way for programs to avoid confusing "
1850 "numbers that correspond to different units. Their integer values can be "
1851 "extracted with pattern matching:"
1852 msgstr ""
1853 "上記のような単純な定義により、異なる単位を持つ数値を混同することなく扱うこと"
1854 "が可能になります。"
1855
1856 #. type: Plain text
1857 #: src/doc/tutorial.md:820
1858 #, fuzzy
1859 #| msgid "~~~~ struct GizmoId(int); ~~~~"
1860 msgid "~~~ # struct Inches(int);"
1861 msgstr ""
1862 "~~~~\n"
1863 "struct GizmoId(int);\n"
1864 "~~~~"
1865
1866 #. type: Plain text
1867 #: src/doc/tutorial.md:827
1868 msgid "# Functions"
1869 msgstr "# 関数"
1870
1871 #. type: Plain text
1872 #: src/doc/tutorial.md:835
1873 #, fuzzy
1874 #| msgid ""
1875 #| "We've already seen several function definitions. Like all other static "
1876 #| "declarations, such as `type`, functions can be declared both at the top "
1877 #| "level and inside other functions (or in modules, which we'll come back to "
1878 #| "[later](#modules-and-crates)). The `fn` keyword introduces a function. A "
1879 #| "function has an argument list, which is a parenthesized list of `expr: "
1880 #| "type` pairs separated by commas. An arrow `->` separates the argument "
1881 #| "list and the function's return type."
1882 msgid ""
1883 "We've already seen several function definitions. Like all other static "
1884 "declarations, such as `type`, functions can be declared both at the top "
1885 "level and inside other functions (or in modules, which we'll come back to "
1886 "[later](#crates-and-the-module-system)). The `fn` keyword introduces a "
1887 "function. A function has an argument list, which is a parenthesized list of "
1888 "`name: type` pairs separated by commas. An arrow `->` separates the argument "
1889 "list and the function's return type."
1890 msgstr ""
1891 "関数定義はこれまでに何度か登場しています。他の静的な宣言 (`type` など)と同様"
1892 "に、関数はトップレベルまたは、他の関数の内部、モジュールの内部で定義すること"
1893 "ができます (モジュールについては、[後述](#モジュールとクレート)します) 。"
1894
1895 #. type: Plain text
1896 #: src/doc/tutorial.md:841
1897 #, fuzzy, no-wrap
1898 #| msgid "~~~~ fn line(a: int, b: int, x: int) -> int { a * x + b } fn oops(a: int, b: int, x: int) -> ()  { a * x + b; }"
1899 msgid ""
1900 "~~~~\n"
1901 "fn line(a: int, b: int, x: int) -> int {\n"
1902 "    return a * x + b;\n"
1903 "}\n"
1904 "~~~~\n"
1905 msgstr ""
1906 "~~~~\n"
1907 "fn line(a: int, b: int, x: int) -> int { a * x + b }\n"
1908 "fn oops(a: int, b: int, x: int) -> ()  { a * x + b; }"
1909
1910 #. type: Plain text
1911 #: src/doc/tutorial.md:846
1912 msgid ""
1913 "The `return` keyword immediately returns from the body of a function. It is "
1914 "optionally followed by an expression to return. A function can also return a "
1915 "value by having its top-level block produce an expression."
1916 msgstr ""
1917 "`return` キーワードにより、呼び出し中の関数を即座に復帰させることができます。"
1918 "`return` の後に式を書くことで、呼び出し元へ戻り値として返すことも可能です。ま"
1919 "た、関数トップレベルのブロックを式と解釈した場合の値 (ブロック内最後の式の"
1920 "値) も関数の戻り値になります。"
1921
1922 #. type: Plain text
1923 #: src/doc/tutorial.md:852
1924 #, fuzzy, no-wrap
1925 #| msgid "~~~~ fn line(a: int, b: int, x: int) -> int { a * x + b } fn oops(a: int, b: int, x: int) -> ()  { a * x + b; }"
1926 msgid ""
1927 "~~~~\n"
1928 "fn line(a: int, b: int, x: int) -> int {\n"
1929 "    a * x + b\n"
1930 "}\n"
1931 "~~~~\n"
1932 msgstr ""
1933 "~~~~\n"
1934 "fn line(a: int, b: int, x: int) -> int { a * x + b }\n"
1935 "fn oops(a: int, b: int, x: int) -> ()  { a * x + b; }"
1936
1937 #. type: Plain text
1938 #: src/doc/tutorial.md:859
1939 msgid ""
1940 "It's better Rust style to write a return value this way instead of writing "
1941 "an explicit `return`. The utility of `return` comes in when returning early "
1942 "from a function. Functions that do not return a value are said to return "
1943 "nil, `()`, and both the return type and the return value may be omitted from "
1944 "the definition. The following two functions are equivalent."
1945 msgstr ""
1946 "Rust では、明示的に `return` を書くのではなく、上記のような方法で戻り値を返す"
1947 "スタイルが推奨されています。 `return` は、関数を途中で復帰させたい場合に使い"
1948 "ます。値を返さない関数は、 nil `()` を返す関数として取り扱われ、関数の戻り値"
1949 "の型や、戻り値を返す処理を省略することが可能です。以下の2つの関数は等価です。"
1950
1951 #. type: Plain text
1952 #: src/doc/tutorial.md:862
1953 msgid "~~~~ fn do_nothing_the_hard_way() -> () { return (); }"
1954 msgstr ""
1955 "~~~~\n"
1956 "fn do_nothing_the_hard_way() -> () { return (); }"
1957
1958 #. type: Plain text
1959 #: src/doc/tutorial.md:865
1960 msgid "fn do_nothing_the_easy_way() { } ~~~~"
1961 msgstr ""
1962 "fn do_nothing_the_easy_way() { }\n"
1963 "~~~~"
1964
1965 #. type: Plain text
1966 #: src/doc/tutorial.md:867
1967 msgid ""
1968 "Ending the function with a semicolon like so is equivalent to returning `()`."
1969 msgstr "以下のように、セミコロンで終わる関数は `()` を返す関数と等価です。"
1970
1971 #. type: Plain text
1972 #: src/doc/tutorial.md:871
1973 msgid ""
1974 "~~~~ fn line(a: int, b: int, x: int) -> int { a * x + b } fn oops(a: int, b: "
1975 "int, x: int) -> ()  { a * x + b; }"
1976 msgstr ""
1977 "~~~~\n"
1978 "fn line(a: int, b: int, x: int) -> int { a * x + b }\n"
1979 "fn oops(a: int, b: int, x: int) -> ()  { a * x + b; }"
1980
1981 #. type: Plain text
1982 #: src/doc/tutorial.md:875
1983 msgid "assert!(8 == line(5, 3, 1)); assert!(() == oops(5, 3, 1)); ~~~~"
1984 msgstr ""
1985 "assert!(8 == line(5, 3, 1));\n"
1986 "assert!(() == oops(5, 3, 1));\n"
1987 "~~~~"
1988
1989 #. type: Plain text
1990 #: src/doc/tutorial.md:879
1991 msgid ""
1992 "As with `match` expressions and `let` bindings, function arguments support "
1993 "pattern destructuring. Like `let`, argument patterns must be irrefutable, as "
1994 "in this example that unpacks the first value from a tuple and returns it."
1995 msgstr ""
1996 "`match` 式や `let` による変数定義のように、関数の引数もパターンによる "
1997 "destructuring をサポートしています。`let` と同様、引数のパターンは 不可反駁 "
1998 "(irrefutable) でなければなりません。以下の例では、タプルの最初の要素を取得"
1999 "し、呼び出し元へ返します。"
2000
2001 #. type: Plain text
2002 #: src/doc/tutorial.md:883
2003 msgid "~~~ fn first((value, _): (int, f64)) -> int { value } ~~~"
2004 msgstr ""
2005 "~~~\n"
2006 "fn first((value, _): (int, f64)) -> int { value }\n"
2007 "~~~"
2008
2009 #. type: Plain text
2010 #: src/doc/tutorial.md:889
2011 msgid ""
2012 "A *destructor* is a function responsible for cleaning up the resources used "
2013 "by an object when it is no longer accessible. Destructors can be defined to "
2014 "handle the release of resources like files, sockets and heap memory."
2015 msgstr ""
2016 "**デストラクタ** はアクセスできなくなったオブジェクトから利用されていたリソー"
2017 "スを解放する役割を持つ関数です。デストラクタはファイルやソケット、ヒープメモ"
2018 "リのようなリソースの解放を処理するために定義することができます。"
2019
2020 #. type: Plain text
2021 #: src/doc/tutorial.md:893
2022 #, fuzzy
2023 #| msgid ""
2024 #| "Objects are never accessible after their destructor has been called, so "
2025 #| "there are no dynamic failures from accessing freed resources. When a task "
2026 #| "fails, the destructors of all objects in the task are called."
2027 msgid ""
2028 "Objects are never accessible after their destructor has been called, so no "
2029 "dynamic failures are possible from accessing freed resources. When a task "
2030 "fails, destructors of all objects in the task are called."
2031 msgstr ""
2032 "オブジェクトは、デストラクタが呼び出された後にアクセス不能になります。そのた"
2033 "め、解放済みリソースへアクセスしたことによる動的なエラーは発生しません。タス"
2034 "クの実行に失敗した場合、タスクに属するすべてのオブジェクトのデストラクタが呼"
2035 "び出されます。"
2036
2037 #. type: Plain text
2038 #: src/doc/tutorial.md:895
2039 msgid ""
2040 "The `~` sigil represents a unique handle for a memory allocation on the heap:"
2041 msgstr ""
2042 "シジル `~` はヒープに獲得されたメモリへのユニークな (唯一の) ハンドルを表しま"
2043 "す。"
2044
2045 #. type: Plain text
2046 #: src/doc/tutorial.md:907
2047 msgid ""
2048 "Rust includes syntax for heap memory allocation in the language since it's "
2049 "commonly used, but the same semantics can be implemented by a type with a "
2050 "custom destructor."
2051 msgstr ""
2052 "Rust はヒープメモリ獲得のための構文を持っています。これは、ヒープメモリ獲得が"
2053 "よく利用されるというのが理由ですが、同じ動作は独自のデストラクタを持つ型によ"
2054 "り実装することが可能です。"
2055
2056 #. type: Plain text
2057 #: src/doc/tutorial.md:909
2058 msgid "# Ownership"
2059 msgstr "# 所有権"
2060
2061 #. type: Plain text
2062 #: src/doc/tutorial.md:914
2063 msgid ""
2064 "Rust formalizes the concept of object ownership to delegate management of an "
2065 "object's lifetime to either a variable or a task-local garbage collector. An "
2066 "object's owner is responsible for managing the lifetime of the object by "
2067 "calling the destructor, and the owner determines whether the object is "
2068 "mutable."
2069 msgstr ""
2070 "Rust は、オブジェクトの寿命の管理を変数またはタスクローカルのガベージコレクタ"
2071 "に委譲するために、オブジェクトの所有権という考え方を取り入れています。オブ"
2072 "ジェクトの所有者はデストラクタを呼び出すことにより、オブジェクトの寿命を管理"
2073 "する責任を負っています。また、所有者はオブジェクトがミュータブルかどうかも判"
2074 "断します。"
2075
2076 #. type: Plain text
2077 #: src/doc/tutorial.md:918
2078 #, fuzzy
2079 #| msgid ""
2080 #| "Ownership is recursive, so mutability is inherited recursively and a "
2081 #| "destructor destroys the contained tree of owned objects. Variables are "
2082 #| "top-level owners and destroy the contained object when they go out of "
2083 #| "scope. A box managed by the garbage collector starts a new ownership "
2084 #| "tree, and the destructor is called when it is collected."
2085 msgid ""
2086 "Ownership is recursive, so mutability is inherited recursively and a "
2087 "destructor destroys the contained tree of owned objects. Variables are top-"
2088 "level owners and destroy the contained object when they go out of scope."
2089 msgstr ""
2090 "所有権は再帰的であるため、ミュータビリティは再帰的に継承され、デストラクタは"
2091 "所有しているオブジェクトの含まれているツリーを破壊します。変数はトップレベル"
2092 "の所有者です。変数の存在しているスコープを抜けるタイミングで、変数は所有して"
2093 "いるオブジェクトを破棄します。ガベージコレクタによって管理されるボックスは、"
2094 "新しい所有権ツリーを生成し、ガベージコレクタによりオブジェクトが回収されると"
2095 "きにデストラクタが呼び出されます。"
2096
2097 #. type: Plain text
2098 #: src/doc/tutorial.md:922
2099 msgid ""
2100 "~~~~ // the struct owns the objects contained in the `x` and `y` fields "
2101 "struct Foo { x: int, y: ~int }"
2102 msgstr ""
2103 "~~~~\n"
2104 "// この構造体はフィールド `x` と `y` に含まれるオブジェクトを所有している\n"
2105 "struct Foo { x: int, y: ~int }"
2106
2107 #. type: Plain text
2108 #: src/doc/tutorial.md:929
2109 #, no-wrap
2110 msgid ""
2111 "{\n"
2112 "    // `a` is the owner of the struct, and thus the owner of the struct's fields\n"
2113 "    let a = Foo { x: 5, y: ~10 };\n"
2114 "}\n"
2115 "// when `a` goes out of scope, the destructor for the `~int` in the struct's\n"
2116 "// field is called\n"
2117 msgstr ""
2118 "{\n"
2119 "    // `a` は構造体の所有者であり、構造体のフィールドの所有者でもある\n"
2120 "    let a = Foo { x: 5, y: ~10 };\n"
2121 "}\n"
2122 "// `a` の含まれているスコープから抜けるとき、 構造体のフィールドの `~int` のデストラクタが呼ばれる\n"
2123
2124 #. type: Plain text
2125 #: src/doc/tutorial.md:934
2126 msgid ""
2127 "// `b` is mutable, and the mutability is inherited by the objects it owns "
2128 "let mut b = Foo { x: 5, y: ~10 }; b.x = 10; ~~~~"
2129 msgstr ""
2130 "// `b` はミュータブルなので、所有しているオブジェクトにもミュターブル性が継承"
2131 "される\n"
2132 "let mut b = Foo { x: 5, y: ~10 };\n"
2133 "b.x = 10;\n"
2134 "~~~~"
2135
2136 #. type: Plain text
2137 #: src/doc/tutorial.md:941
2138 #, fuzzy
2139 #| msgid ""
2140 #| "If an object doesn't contain garbage-collected boxes, it consists of a "
2141 #| "single ownership tree and is given the `Owned` trait which allows it to "
2142 #| "be sent between tasks. Custom destructors can only be implemented "
2143 #| "directly on types that are `Owned`, but garbage-collected boxes can still "
2144 #| "*contain* types with custom destructors."
2145 msgid ""
2146 "If an object doesn't contain any non-Send types, it consists of a single "
2147 "ownership tree and is itself given the `Send` trait which allows it to be "
2148 "sent between tasks. Custom destructors can only be implemented directly on "
2149 "types that are `Send`, but non-`Send` types can still *contain* types with "
2150 "custom destructors. Example of types which are not `Send` are [`Gc<T>`][gc] "
2151 "and [`Rc<T>`][rc], the shared-ownership types."
2152 msgstr ""
2153 "オブジェクトにガベージコレクトされるボックスが含まれていない場合、オブジェク"
2154 "トは単一の継承ツリーからの構成され、`Owned` トレイトが付与されます。`Owned` "
2155 "トレイトが付与されたデータは、タスク間を跨いで受け渡すことが可能です。独自の"
2156 "デストラクタは、`Owned` トレイトを満たす型に対して直接実装されなければなりま"
2157 "せんが、ガベージコレクトされるボックスが独自のデストラクタをもつ型を **含む"
2158 "** ことは依然可能です。"
2159
2160 #. type: Plain text
2161 #: src/doc/tutorial.md:944
2162 #, fuzzy
2163 #| msgid ""
2164 #| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
2165 #| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
2166 msgid ""
2167 "[gc]: http://static.rust-lang.org/doc/master/std/gc/struct.Gc.html [rc]: "
2168 "http://static.rust-lang.org/doc/master/std/rc/struct.Rc.html"
2169 msgstr ""
2170 "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
2171 "[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
2172
2173 #. type: Plain text
2174 #: src/doc/tutorial.md:946
2175 #, fuzzy
2176 #| msgid "# Introduction"
2177 msgid "# Implementing a linked list"
2178 msgstr "# イントロダクション"
2179
2180 #. type: Plain text
2181 #: src/doc/tutorial.md:973
2182 #, fuzzy
2183 #| msgid "# Boxes"
2184 msgid "## Boxes"
2185 msgstr "# ボックス"
2186
2187 #. type: Plain text
2188 #: src/doc/tutorial.md:986
2189 #, fuzzy, no-wrap
2190 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
2191 msgid ""
2192 "struct Foo {\n"
2193 "    a: u32,\n"
2194 "    b: u32,\n"
2195 "    c: u32,\n"
2196 "    d: u32\n"
2197 "}\n"
2198 msgstr ""
2199 "~~~~ {.ignore}\n"
2200 "// main.rs\n"
2201 "extern crate world;\n"
2202 "fn main() { println(~\"hello \" + world::explore()); }\n"
2203 "~~~~"
2204
2205 #. type: Plain text
2206 #: src/doc/tutorial.md:1047
2207 #, fuzzy
2208 #| msgid "# Move semantics"
2209 msgid "## Move semantics"
2210 msgstr "# ムーブセマンティクス"
2211
2212 #. type: Plain text
2213 #: src/doc/tutorial.md:1091
2214 #, fuzzy
2215 #| msgid ""
2216 #| "~~~~ let x = ~5; let y = x.clone(); // y is a newly allocated box let z = "
2217 #| "x; // no new memory allocated, x can no longer be used ~~~~"
2218 msgid ""
2219 "~~~~ let x = ~5; let y = x.clone(); // `y` is a newly allocated box let z = "
2220 "x; // no new memory allocated, `x` can no longer be used ~~~~"
2221 msgstr ""
2222 "~~~~\n"
2223 "let x = ~5;\n"
2224 "let y = x.clone();\n"
2225 "// y は新しく獲得されるボックス\n"
2226 "let z = x; // 新たなメモリの獲得は行われない。x を使うことはできなくなる\n"
2227 "~~~~"
2228
2229 #. type: Plain text
2230 #: src/doc/tutorial.md:1120
2231 msgid ""
2232 "~~~~ let r = ~13; let mut s = r; // box becomes mutable *s += 1; let t = "
2233 "s; // box becomes immutable ~~~~"
2234 msgstr ""
2235 "~~~~\n"
2236 "let r = ~13;\n"
2237 "let mut s = r; // ボックスはミュータブルになる\n"
2238 "*s += 1;\n"
2239 "let t = s; // ボックスはイミュータブルになる\n"
2240 "~~~~"
2241
2242 #. type: Plain text
2243 #: src/doc/tutorial.md:1144
2244 #, fuzzy
2245 msgid "## References"
2246 msgstr "# ポインタのデリファレンス"
2247
2248 #. type: Plain text
2249 #: src/doc/tutorial.md:1190
2250 #, fuzzy
2251 #| msgid "## Using other crates"
2252 msgid "## Lists of other types"
2253 msgstr "## 他のクレートの利用"
2254
2255 #. type: Plain text
2256 #: src/doc/tutorial.md:1322
2257 #, fuzzy
2258 #| msgid "## Managed boxes"
2259 msgid "# More on boxes"
2260 msgstr "## マネージドボックス"
2261
2262 #. type: Plain text
2263 #: src/doc/tutorial.md:1353
2264 msgid "~~~~ let x = 5; // immutable let mut y = 5; // mutable y += 2;"
2265 msgstr ""
2266 "~~~~\n"
2267 "let x = 5; // イミュータブル\n"
2268 "let mut y = 5; // ミュータブル\n"
2269 "y += 2;"
2270
2271 #. type: Plain text
2272 #: src/doc/tutorial.md:1358
2273 #, fuzzy
2274 #| msgid ""
2275 #| "let x = ~5; // immutable let mut y = ~5; // mutable *y += 2; // the * "
2276 #| "operator is needed to access the contained value ~~~~"
2277 msgid ""
2278 "let x = ~5; // immutable let mut y = ~5; // mutable *y += 2; // the `*` "
2279 "operator is needed to access the contained value ~~~~"
2280 msgstr ""
2281 "let x = ~5; // イミュータブル\n"
2282 "let mut y = ~5; // ミュータブル\n"
2283 "*y += 2; // ボックスの中身にアクセスするには、 * 演算子が必要\n"
2284 "~~~~"
2285
2286 #. type: Plain text
2287 #: src/doc/tutorial.md:1367
2288 #, fuzzy
2289 #| msgid ""
2290 #| "Rust's borrowed pointers are a general purpose reference type. In "
2291 #| "contrast with owned boxes, where the holder of an owned box is the owner "
2292 #| "of the pointed-to memory, borrowed pointers never imply ownership. A "
2293 #| "pointer can be borrowed to any object, and the compiler verifies that it "
2294 #| "cannot outlive the lifetime of the object."
2295 msgid ""
2296 "In contrast with owned boxes, where the holder of an owned box is the owner "
2297 "of the pointed-to memory, references never imply ownership - they are "
2298 "\"borrowed\".  A reference can be borrowed to any object, and the compiler "
2299 "verifies that it cannot outlive the lifetime of the object."
2300 msgstr ""
2301 "Rust の借用ポインタ (borrowed pointer) は汎用的な参照型です。所有ボックスの場"
2302 "合、ボックスの所有者が参照されているメモリの所有者となるのに対して、借用ポイ"
2303 "ンタを所有することがメモリを所有を意味することはありません。ポインタは任意の"
2304 "オブジェクトから借用することが可能で、参照先のオブジェクトよりもポインタが長"
2305 "生きしないことがコンパイラにより保証されます。"
2306
2307 #. type: Plain text
2308 #: src/doc/tutorial.md:1369
2309 msgid "As an example, consider a simple struct type, `Point`:"
2310 msgstr "例として、シンプルな構造体型の `Point` について考えます。"
2311
2312 #. type: Plain text
2313 #: src/doc/tutorial.md:1376
2314 #, fuzzy, no-wrap
2315 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
2316 msgid ""
2317 "~~~\n"
2318 "struct Point {\n"
2319 "    x: f64,\n"
2320 "    y: f64\n"
2321 "}\n"
2322 "~~~~\n"
2323 msgstr ""
2324 "~~~~ {.ignore}\n"
2325 "// main.rs\n"
2326 "extern crate world;\n"
2327 "fn main() { println(~\"hello \" + world::explore()); }\n"
2328 "~~~~"
2329
2330 #. type: Plain text
2331 #: src/doc/tutorial.md:1380
2332 msgid ""
2333 "We can use this simple definition to allocate points in many different ways. "
2334 "For example, in this code, each of these three local variables contains a "
2335 "point, but allocated in a different location:"
2336 msgstr ""
2337 "シンプルな定義ですが、この定義を使って `Point` 型のオブジェクトを様々な方法で"
2338 "割り当てることができます。例えば、このコードの3つのローカル変数は、それぞれ異"
2339 "なった場所に `Point` 型のオブジェクトを割り当てています。"
2340
2341 #. type: Plain text
2342 #: src/doc/tutorial.md:1387
2343 #, fuzzy, no-wrap
2344 #| msgid "~~~~ {.ignore} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
2345 msgid ""
2346 "~~~\n"
2347 "# struct Point { x: f64, y: f64 }\n"
2348 "let on_the_stack : Point  =  Point { x: 3.0, y: 4.0 };\n"
2349 "let managed_box  : @Point = @Point { x: 5.0, y: 1.0 };\n"
2350 "let owned_box    : ~Point = ~Point { x: 7.0, y: 9.0 };\n"
2351 "~~~\n"
2352 msgstr ""
2353 "~~~~ {.ignore}\n"
2354 "# struct Point { x: f64, y: f64 }\n"
2355 "let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
2356 "let origin = Point { x: 0.0, y: 0.0 };"
2357
2358 #. type: Plain text
2359 #: src/doc/tutorial.md:1397
2360 #, fuzzy
2361 #| msgid ""
2362 #| "Suppose we want to write a procedure that computes the distance between "
2363 #| "any two points, no matter where they are stored. For example, we might "
2364 #| "like to compute the distance between `on_the_stack` and `managed_box`, or "
2365 #| "between `managed_box` and `owned_box`. One option is to define a function "
2366 #| "that takes two arguments of type point—that is, it takes the points by "
2367 #| "value. But this will cause the points to be copied when we call the "
2368 #| "function. For points, this is probably not so bad, but often copies are "
2369 #| "expensive. So we’d like to define a function that takes the points by "
2370 #| "pointer. We can use borrowed pointers to do this:"
2371 msgid ""
2372 "Suppose we want to write a procedure that computes the distance between any "
2373 "two points, no matter where they are stored. For example, we might like to "
2374 "compute the distance between `on_the_stack` and `managed_box`, or between "
2375 "`managed_box` and `owned_box`. One option is to define a function that takes "
2376 "two arguments of type point—that is, it takes the points by value. But this "
2377 "will cause the points to be copied when we call the function. For points, "
2378 "this is probably not so bad, but often copies are expensive. So we’d like to "
2379 "define a function that takes the points by pointer. We can use references to "
2380 "do this:"
2381 msgstr ""
2382 "`Point` 型のオブジェクトの割り当て先がどこであったとしても利用可能な、任意の "
2383 "2 点間の距離を計算する処理を書きたいとします。例えば、 `on_the_stack`, "
2384 "`managed_box` 間や `managed_box`, `owned_box` 間の距離を計算する処理です。 1"
2385 "つ目の実装方法として、2つの `Point` 型オブジェクトを引数にとる関数を定義する"
2386 "方法、すなわち、オブジェクトを値で受け渡す方法があります。しかし、この方法で"
2387 "は関数呼び出し時に `Point` オブジェクトのコピーが行われます。`Point` オブジェ"
2388 "クトの場合、このような実装はそれほど悪いものではないでしょうが、コピー処理の"
2389 "コストは高い場合もあります。したがって、`Point` オブジェクトをポインタ渡しす"
2390 "る関数を定義する必要があります。そのために、借用ポインタを利用することが可能"
2391 "です。"
2392
2393 #. type: Plain text
2394 #: src/doc/tutorial.md:1419
2395 #, fuzzy, no-wrap
2396 #| msgid "~~~~ {.ignore} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
2397 msgid ""
2398 "~~~\n"
2399 "# struct Point{ x: f64, y: f64 };\n"
2400 "# let on_the_stack : Point  =  Point { x: 3.0, y: 4.0 };\n"
2401 "# let managed_box  : @Point = @Point { x: 5.0, y: 1.0 };\n"
2402 "# let owned_box    : ~Point = ~Point { x: 7.0, y: 9.0 };\n"
2403 "# fn compute_distance(p1: &Point, p2: &Point) -> f64 { 0.0 }\n"
2404 "compute_distance(&on_the_stack, managed_box);\n"
2405 "compute_distance(managed_box, owned_box);\n"
2406 "~~~\n"
2407 msgstr ""
2408 "~~~~ {.ignore}\n"
2409 "# struct Point { x: f64, y: f64 }\n"
2410 "let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
2411 "let origin = Point { x: 0.0, y: 0.0 };"
2412
2413 #. type: Plain text
2414 #: src/doc/tutorial.md:1426
2415 #, fuzzy
2416 #| msgid ""
2417 #| "Here the `&` operator is used to take the address of the variable "
2418 #| "`on_the_stack`; this is because `on_the_stack` has the type `Point` (that "
2419 #| "is, a struct value) and we have to take its address to get a value. We "
2420 #| "also call this _borrowing_ the local variable `on_the_stack`, because we "
2421 #| "are creating an alias: that is, another route to the same data."
2422 msgid ""
2423 "Here the `&` operator is used to take the address of the variable "
2424 "`on_the_stack`; this is because `on_the_stack` has the type `Point` (that "
2425 "is, a struct value) and we have to take its address to get a reference. We "
2426 "also call this _borrowing_ the local variable `on_the_stack`, because we are "
2427 "creating an alias: that is, another route to the same data."
2428 msgstr ""
2429 "ここで `&` 演算子は `on_the_stack` 変数のアドレスを取得するために使われていま"
2430 "す。これは、 `on_the_stack` の型は `Point` (つまり、構造体の値) であり、呼び"
2431 "出した関数から値を取得させるため、構造体のアドレスを渡す必要があるからです。"
2432 "値の別名 (エイリアス)、すなわち、同じデータへアクセスするための別の方法を提供"
2433 "するので、このような操作のことをローカル変数 `on_the_stack` の __借用__ "
2434 "(_borrowing_) と呼びます。"
2435
2436 #. type: Plain text
2437 #: src/doc/tutorial.md:1432
2438 #, fuzzy
2439 #| msgid ""
2440 #| "In the case of the boxes `managed_box` and `owned_box`, however, no "
2441 #| "explicit action is necessary. The compiler will automatically convert a "
2442 #| "box like `@point` or `~point` to a borrowed pointer like `&point`. This "
2443 #| "is another form of borrowing; in this case, the contents of the managed/"
2444 #| "owned box are being lent out."
2445 msgid ""
2446 "In the case of the boxes `managed_box` and `owned_box`, however, no explicit "
2447 "action is necessary. The compiler will automatically convert a box like "
2448 "`@point` or `~point` to a reference like `&point`. This is another form of "
2449 "borrowing; in this case, the contents of the managed/owned box are being "
2450 "lent out."
2451 msgstr ""
2452 "ボックスである `managed_box` と `owned_box` の場合は、特に明示的な操作を行う"
2453 "必要はありません。コンパイラは `@point` や `~point` のようなボックスを自動的"
2454 "に `&point` のような借用ポインタへと変換します。これは、別の形態の借用 "
2455 "(borrowing) です。この場合、マネージド/所有ボックスの内容が貸し出されていま"
2456 "す。"
2457
2458 #. type: Plain text
2459 #: src/doc/tutorial.md:1441
2460 #, fuzzy
2461 #| msgid ""
2462 #| "Whenever a value is borrowed, there are some limitations on what you can "
2463 #| "do with the original. For example, if the contents of a variable have "
2464 #| "been lent out, you cannot send that variable to another task, nor will "
2465 #| "you be permitted to take actions that might cause the borrowed value to "
2466 #| "be freed or to change its type. This rule should make intuitive sense: "
2467 #| "you must wait for a borrowed value to be returned (that is, for the "
2468 #| "borrowed pointer to go out of scope) before you can make full use of it "
2469 #| "again."
2470 msgid ""
2471 "Whenever a value is borrowed, there are some limitations on what you can do "
2472 "with the original. For example, if the contents of a variable have been lent "
2473 "out, you cannot send that variable to another task, nor will you be "
2474 "permitted to take actions that might cause the borrowed value to be freed or "
2475 "to change its type. This rule should make intuitive sense: you must wait for "
2476 "a borrowed value to be returned (that is, for the reference to go out of "
2477 "scope) before you can make full use of it again."
2478 msgstr ""
2479 "値が借用されている間、借用元の値に対して行える操作がいくらか制限されます。例"
2480 "えば、変数の内容が貸し出された場合、その変数を他のタスクに送信することはでき"
2481 "ませんし、借用された値を解放したり、型が変化させるような操作も行うことができ"
2482 "ません。このルールは理にかなったものでしょう。貸し出した値を最大限に活用する "
2483 "(make full use of it) ためには、貸し出した値の返却 (借用ポインタが存在するス"
2484 "コープを抜ける) を待たなければなりません。"
2485
2486 #. type: Plain text
2487 #: src/doc/tutorial.md:1444
2488 #, fuzzy
2489 #| msgid ""
2490 #| "For a more in-depth explanation of borrowed pointers, read the [borrowed "
2491 #| "pointer tutorial][borrowtut]."
2492 msgid ""
2493 "For a more in-depth explanation of references and lifetimes, read the "
2494 "[references and lifetimes guide][lifetimes]."
2495 msgstr ""
2496 "借用ポインタの詳細については、[借用ポインタのチュートリアル][borrowtut]を参照"
2497 "してください。"
2498
2499 #. type: Plain text
2500 #: src/doc/tutorial.md:1446
2501 msgid "## Freezing"
2502 msgstr "## 凍結"
2503
2504 #. type: Plain text
2505 #: src/doc/tutorial.md:1450
2506 #, fuzzy
2507 #| msgid ""
2508 #| "Borrowing an immutable pointer to an object freezes it and prevents "
2509 #| "mutation.  `Owned` objects have freezing enforced statically at compile-"
2510 #| "time."
2511 msgid ""
2512 "Lending an immutable pointer to an object freezes it and prevents mutation.  "
2513 "`Freeze` objects have freezing enforced statically at compile-time. An "
2514 "example of a non-`Freeze` type is [`RefCell<T>`][refcell]."
2515 msgstr ""
2516 "オブジェクトへのイミュータブルな (借用) ポインタを借用した場合、借用されたオ"
2517 "ブジェクトは凍結 (freezing) され、変更することができなくなります。`Owned` ト"
2518 "レイトが付与されたオブジェクトは、コンパイル時の静的解析により、強制的に凍結"
2519 "されます (凍結された値を変更しようとすると、コンパイルエラーとなります)。"
2520
2521 #. type: Plain text
2522 #: src/doc/tutorial.md:1459
2523 #, fuzzy, no-wrap
2524 #| msgid ""
2525 #| "~~~~\n"
2526 #| "let mut x = 5;\n"
2527 #| "{\n"
2528 #| "    let y = &x; // x is now frozen, it cannot be modified\n"
2529 #| "}\n"
2530 #| "// x is now unfrozen again\n"
2531 #| "# x = 3;\n"
2532 #| "~~~~\n"
2533 msgid ""
2534 "~~~~\n"
2535 "let mut x = 5;\n"
2536 "{\n"
2537 "    let y = &x; // `x` is now frozen, it cannot be modified\n"
2538 "}\n"
2539 "// `x` is now unfrozen again\n"
2540 "# x = 3;\n"
2541 "~~~~\n"
2542 msgstr ""
2543 "~~~~\n"
2544 "let mut x = 5;\n"
2545 "{\n"
2546 "    let y = &x; // x は凍結されたので、変更することができない\n"
2547 "}\n"
2548 "// x の凍結状態は解除される\n"
2549 "# x = 3;\n"
2550 "~~~~\n"
2551
2552 #. type: Plain text
2553 #: src/doc/tutorial.md:1461
2554 #, fuzzy
2555 #| msgid ""
2556 #| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
2557 #| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
2558 msgid ""
2559 "[refcell]: http://static.rust-lang.org/doc/master/std/cell/struct.RefCell."
2560 "html"
2561 msgstr ""
2562 "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
2563 "[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
2564
2565 #. type: Plain text
2566 #: src/doc/tutorial.md:1463
2567 msgid "# Dereferencing pointers"
2568 msgstr "# ポインタのデリファレンス"
2569
2570 #. type: Plain text
2571 #: src/doc/tutorial.md:1466
2572 msgid ""
2573 "Rust uses the unary star operator (`*`) to access the contents of a box or "
2574 "pointer, similarly to C."
2575 msgstr ""
2576 "Rust では、C と同様、ボックスの内容やポインタの参照先にアクセスするためには単"
2577 "項スター演算子 (`*`) を使います。"
2578
2579 #. type: Plain text
2580 #: src/doc/tutorial.md:1471
2581 msgid "~~~ let managed = @10; let owned = ~20; let borrowed = &30;"
2582 msgstr ""
2583 "~~~\n"
2584 "let managed = @10;\n"
2585 "let owned = ~20;\n"
2586 "let borrowed = &30;"
2587
2588 #. type: Plain text
2589 #: src/doc/tutorial.md:1474
2590 msgid "let sum = *managed + *owned + *borrowed; ~~~"
2591 msgstr ""
2592 "let sum = *managed + *owned + *borrowed;\n"
2593 "~~~"
2594
2595 #. type: Plain text
2596 #: src/doc/tutorial.md:1478
2597 msgid ""
2598 "Dereferenced mutable pointers may appear on the left hand side of "
2599 "assignments. Such an assignment modifies the value that the pointer points "
2600 "to."
2601 msgstr ""
2602 "ミュータブルなポインタをデリファレンスしたものは、代入文の左辺に置くことがで"
2603 "きます。このような代入文は、ポインタが指す値を変更します。"
2604
2605 #. type: Plain text
2606 #: src/doc/tutorial.md:1482
2607 #, fuzzy
2608 #| msgid "~~~ let managed = @mut 10; let mut owned = ~20;"
2609 msgid "~~~ let managed = @10; let mut owned = ~20;"
2610 msgstr ""
2611 "~~~\n"
2612 "let managed = @mut 10;\n"
2613 "let mut owned = ~20;"
2614
2615 #. type: Plain text
2616 #: src/doc/tutorial.md:1485
2617 msgid "let mut value = 30; let borrowed = &mut value;"
2618 msgstr ""
2619 "let mut value = 30;\n"
2620 "let borrowed = &mut value;"
2621
2622 #. type: Plain text
2623 #: src/doc/tutorial.md:1493
2624 msgid ""
2625 "Pointers have high operator precedence, but lower precedence than the dot "
2626 "operator used for field and method access. This precedence order can "
2627 "sometimes make code awkward and parenthesis-filled."
2628 msgstr ""
2629 "ポインタ演算子の優先順位は高いですが、フィールドやメソッドのアクセスに用いる"
2630 "ドット演算子よりは優先順位は低いです。この優先順位により、コードが不格好で括"
2631 "弧だらけなものになることがあります。"
2632
2633 #. type: Plain text
2634 #: src/doc/tutorial.md:1503
2635 #, fuzzy
2636 #| msgid ""
2637 #| "~~~ # struct Point { x: f64, y: f64 } # enum Shape { Rectangle(Point, "
2638 #| "Point) } # impl Shape { fn area(&self) -> int { 0 } } let start = @Point "
2639 #| "{ x: 10f, y: 20f }; let end = ~Point { x: (*start).x + 100f, y: (*start)."
2640 #| "y + 100f }; let rect = &Rectangle(*start, *end); let area = (*rect)."
2641 #| "area(); ~~~"
2642 msgid ""
2643 "~~~ # struct Point { x: f64, y: f64 } # enum Shape { Rectangle(Point, "
2644 "Point) } # impl Shape { fn area(&self) -> int { 0 } } let start = @Point "
2645 "{ x: 10.0, y: 20.0 }; let end = ~Point { x: (*start).x + 100.0, y: (*start)."
2646 "y + 100.0 }; let rect = &Rectangle(*start, *end); let area = (*rect).area(); "
2647 "~~~"
2648 msgstr ""
2649 "~~~\n"
2650 "# struct Point { x: f64, y: f64 }\n"
2651 "# enum Shape { Rectangle(Point, Point) }\n"
2652 "# impl Shape { fn area(&self) -> int { 0 } }\n"
2653 "let start = @Point { x: 10f, y: 20f };\n"
2654 "let end = ~Point { x: (*start).x + 100f, y: (*start).y + 100f };\n"
2655 "let rect = &Rectangle(*start, *end);\n"
2656 "let area = (*rect).area();\n"
2657 "~~~"
2658
2659 #. type: Plain text
2660 #: src/doc/tutorial.md:1507
2661 msgid ""
2662 "To combat this ugliness the dot operator applies _automatic pointer "
2663 "dereferencing_ to the receiver (the value on the left-hand side of the dot), "
2664 "so in most cases, explicitly dereferencing the receiver is not necessary."
2665 msgstr ""
2666 "コードが醜くなるのを防ぐため、ドット演算子はレシーバ (ドットの左にある値) の "
2667 "__ポインタを自動的にデリファレンス__ します。これにより、ほとんどのケースでは"
2668 "レシーバを明示的にデリファレンスする必要がなくなります。"
2669
2670 #. type: Plain text
2671 #: src/doc/tutorial.md:1517
2672 #, fuzzy
2673 #| msgid ""
2674 #| "~~~ # struct Point { x: f64, y: f64 } # enum Shape { Rectangle(Point, "
2675 #| "Point) } # impl Shape { fn area(&self) -> int { 0 } } let start = @Point "
2676 #| "{ x: 10f, y: 20f }; let end = ~Point { x: start.x + 100f, y: start.y + "
2677 #| "100f }; let rect = &Rectangle(*start, *end); let area = rect.area(); ~~~"
2678 msgid ""
2679 "~~~ # struct Point { x: f64, y: f64 } # enum Shape { Rectangle(Point, "
2680 "Point) } # impl Shape { fn area(&self) -> int { 0 } } let start = @Point "
2681 "{ x: 10.0, y: 20.0 }; let end = ~Point { x: start.x + 100.0, y: start.y + "
2682 "100.0 }; let rect = &Rectangle(*start, *end); let area = rect.area(); ~~~"
2683 msgstr ""
2684 "~~~\n"
2685 "# struct Point { x: f64, y: f64 }\n"
2686 "# enum Shape { Rectangle(Point, Point) }\n"
2687 "# impl Shape { fn area(&self) -> int { 0 } }\n"
2688 "let start = @Point { x: 10f, y: 20f };\n"
2689 "let end = ~Point { x: start.x + 100f, y: start.y + 100f };\n"
2690 "let rect = &Rectangle(*start, *end);\n"
2691 "let area = rect.area();\n"
2692 "~~~"
2693
2694 #. type: Plain text
2695 #: src/doc/tutorial.md:1521
2696 msgid ""
2697 "You can write an expression that dereferences any number of pointers "
2698 "automatically. For example, if you feel inclined, you could write something "
2699 "silly like"
2700 msgstr ""
2701 "1つのドット演算子で何度も自動デリファレンスが行うことができます。例えば、やろ"
2702 "うと思えば以下のような馬鹿げたものを書くこともできます。"
2703
2704 #. type: Plain text
2705 #: src/doc/tutorial.md:1527
2706 #, fuzzy
2707 #| msgid ""
2708 #| "~~~ # struct Point { x: f64, y: f64 } let point = &@~Point { x: 10f, y: "
2709 #| "20f }; println(fmt!(\"%f\", point.x)); ~~~"
2710 msgid ""
2711 "~~~ # struct Point { x: f64, y: f64 } let point = &@~Point { x: 10.0, y: "
2712 "20.0 }; println!(\"{:f}\", point.x); ~~~"
2713 msgstr ""
2714 "~~~\n"
2715 "# struct Point { x: f64, y: f64 }\n"
2716 "let point = &@~Point { x: 10f, y: 20f };\n"
2717 "println(fmt!(\"%f\", point.x));\n"
2718 "~~~"
2719
2720 #. type: Plain text
2721 #: src/doc/tutorial.md:1529
2722 msgid "The indexing operator (`[]`) also auto-dereferences."
2723 msgstr "添字演算子 (`[]`) も自動でリファレンスを行います。"
2724
2725 #. type: Plain text
2726 #: src/doc/tutorial.md:1531
2727 msgid "# Vectors and strings"
2728 msgstr "# ベクタと文字列"
2729
2730 #. type: Plain text
2731 #: src/doc/tutorial.md:1535
2732 #, fuzzy
2733 #| msgid ""
2734 #| "A vector is a contiguous section of memory containing zero or more values "
2735 #| "of the same type. Like other types in Rust, vectors can be stored on the "
2736 #| "stack, the local heap, or the exchange heap. Borrowed pointers to vectors "
2737 #| "are also called 'slices'."
2738 msgid ""
2739 "A vector is a contiguous block of memory containing zero or more values of "
2740 "the same type. Rust also supports vector reference types, called slices, "
2741 "which are a view into a block of memory represented as a pointer and a "
2742 "length."
2743 msgstr ""
2744 "ベクタは同じ型の値が0個以上含まれる、メモリ上の連続した部分のことです。Rust "
2745 "の他の型と同様、ベクタもスタック、ローカルヒープ、交換ヒープ (exchange heap) "
2746 "上に格納することができます。ベクトルの借用ポインタは、「スライス」と呼ばれる"
2747 "場合もあります。"
2748
2749 #. type: Plain text
2750 #: src/doc/tutorial.md:1608
2751 msgid "Square brackets denote indexing into a vector:"
2752 msgstr "角括弧はベクタの添字を表します。"
2753
2754 #. type: Plain text
2755 #: src/doc/tutorial.md:1622
2756 msgid "A vector can be destructured using pattern matching:"
2757 msgstr "ベクタはパターンマッチにより destructuring することができます。"
2758
2759 #. type: Plain text
2760 #: src/doc/tutorial.md:1635
2761 #, fuzzy
2762 #| msgid ""
2763 #| "Both vectors and strings support a number of useful [methods](#methods), "
2764 #| "defined in [`std::vec`] and [`std::str`]. Here are some examples."
2765 msgid ""
2766 "Both vectors and strings support a number of useful [methods](#methods), "
2767 "defined in [`std::vec`] and [`std::str`]."
2768 msgstr ""
2769 "ベクタと文字列は、[`std::vec`] と [`std::str`] で定義された、多くの有用な [メ"
2770 "ソッド](#methods) を持ちます。以下にいくつか例を挙げます。"
2771
2772 #. type: Plain text
2773 #: src/doc/tutorial.md:1638
2774 #, fuzzy
2775 #| msgid "[`std::vec`]: std/vec.html [`std::str`]: std/str.html"
2776 msgid "[`std::vec`]: std/vec/index.html [`std::str`]: std/str/index.html"
2777 msgstr ""
2778 "[`std::vec`]: std/vec.html\n"
2779 "[`std::str`]: std/str.html"
2780
2781 #. type: Plain text
2782 #: src/doc/tutorial.md:1650
2783 #, fuzzy
2784 #| msgid "~~~~ use std::task::spawn;"
2785 msgid "~~~ use std::rc::Rc;"
2786 msgstr ""
2787 "~~~~\n"
2788 "use std::task::spawn;"
2789
2790 #. type: Plain text
2791 #: src/doc/tutorial.md:1669
2792 #, fuzzy
2793 #| msgid "~~~~ use std::task::spawn;"
2794 msgid "~~~ use std::gc::Gc;"
2795 msgstr ""
2796 "~~~~\n"
2797 "use std::task::spawn;"
2798
2799 #. type: Plain text
2800 #: src/doc/tutorial.md:1686
2801 msgid "# Closures"
2802 msgstr "# クロージャ"
2803
2804 #. type: Plain text
2805 #: src/doc/tutorial.md:1691
2806 msgid ""
2807 "Named functions, like those we've seen so far, may not refer to local "
2808 "variables declared outside the function: they do not close over their "
2809 "environment (sometimes referred to as \"capturing\" variables in their "
2810 "environment). For example, you couldn't write the following:"
2811 msgstr ""
2812 "これまで登場したような名前のある関数は、関数の外で定義されるローカル変数を参"
2813 "照することはできません。ローカル変数は環境を閉じ込める (環境中の変数を「キャ"
2814 "プチャする」と呼ばれることもあります) ことはありません。例えば、以下のような"
2815 "コードを書くことはできません。"
2816
2817 #. type: Plain text
2818 #: src/doc/tutorial.md:1694
2819 msgid "~~~~ {.ignore} let foo = 10;"
2820 msgstr ""
2821 "~~~~ {.ignore}\n"
2822 "let foo = 10;"
2823
2824 #. type: Plain text
2825 #: src/doc/tutorial.md:1699
2826 #, no-wrap
2827 msgid ""
2828 "fn bar() -> int {\n"
2829 "   return foo; // `bar` cannot refer to `foo`\n"
2830 "}\n"
2831 "~~~~\n"
2832 msgstr ""
2833 "fn bar() -> int {\n"
2834 "   return foo; // `bar` ば `foo` を参照できない\n"
2835 "}\n"
2836 "~~~~\n"
2837
2838 #. type: Plain text
2839 #: src/doc/tutorial.md:1702
2840 msgid ""
2841 "Rust also supports _closures_, functions that can access variables in the "
2842 "enclosing scope."
2843 msgstr ""
2844 "Rust は __クロージャ__ という、周囲のスコープの変数にアクセスできる関数をサ"
2845 "ポートしています。"
2846
2847 #. type: Plain text
2848 #: src/doc/tutorial.md:1705
2849 msgid "~~~~ fn call_closure_with_ten(b: |int|) { b(10); }"
2850 msgstr ""
2851 "~~~~\n"
2852 "fn call_closure_with_ten(b: |int|) { b(10); }"
2853
2854 #. type: Plain text
2855 #: src/doc/tutorial.md:1708
2856 #, fuzzy
2857 #| msgid ""
2858 #| "let captured_var = 20; let closure = |arg| println(fmt!(\"captured_var="
2859 #| "%d, arg=%d\", captured_var, arg));"
2860 msgid ""
2861 "let captured_var = 20; let closure = |arg| println!(\"captured_var={}, "
2862 "arg={}\", captured_var, arg);"
2863 msgstr ""
2864 "let captured_var = 20;\n"
2865 "let closure = |arg| println(fmt!(\"captured_var=%d, arg=%d\", captured_var, "
2866 "arg));"
2867
2868 #. type: Plain text
2869 #: src/doc/tutorial.md:1711
2870 msgid "call_closure_with_ten(closure); ~~~~"
2871 msgstr ""
2872 "call_closure_with_ten(closure);\n"
2873 "~~~~"
2874
2875 #. type: Plain text
2876 #: src/doc/tutorial.md:1717
2877 msgid ""
2878 "Closures begin with the argument list between vertical bars and are followed "
2879 "by a single expression. Remember that a block, `{ <expr1>; <expr2>; ... }`, "
2880 "is considered a single expression: it evaluates to the result of the last "
2881 "expression it contains if that expression is not followed by a semicolon, "
2882 "otherwise the block evaluates to `()`."
2883 msgstr ""
2884 "クロージャはバーティカルバー (`|`) で囲まれた引数リストと、それに続く単一の式"
2885 "から構成されます。ブロック `{ <expr1>; <expr2>; ...}` は単一の式とみなされる"
2886 "ことを思い出してください。ブロックに含まれる最後の式に続けてセミコロンがない"
2887 "場合、ブロックの値は最後の式の値となり、そうでなければ `()` となります。"
2888
2889 #. type: Plain text
2890 #: src/doc/tutorial.md:1722
2891 msgid ""
2892 "The types of the arguments are generally omitted, as is the return type, "
2893 "because the compiler can almost always infer them. In the rare case where "
2894 "the compiler needs assistance, though, the arguments and return types may be "
2895 "annotated."
2896 msgstr ""
2897 "引数の型や戻り値の型は、ほとんどすべての場合においてコンパイラにより推論され"
2898 "るため、通常省略できます。発生するのはまれですが、コンパイラが推論に失敗する"
2899 "場合は、引数と戻り値の型注釈を付けることがあります。"
2900
2901 #. type: Plain text
2902 #: src/doc/tutorial.md:1726
2903 msgid "~~~~ let square = |x: int| -> uint { (x * x) as uint }; ~~~~"
2904 msgstr ""
2905 "~~~~\n"
2906 "let square = |x: int| -> uint { (x * x) as uint };\n"
2907 "~~~~~~~~\n"
2908
2909 #. type: Plain text
2910 #: src/doc/tutorial.md:1730
2911 msgid ""
2912 "There are several forms of closure, each with its own role. The most common, "
2913 "called a _stack closure_, has type `||` and can directly access local "
2914 "variables in the enclosing scope."
2915 msgstr ""
2916 "クロージャにはいくつかの形態があり、それぞれに独自の役割があります。最も一般"
2917 "的なのはスタッククロージャと呼ばれるもので、 `||` という型を持ち、外側のロー"
2918 "カル変数に直接アクセスすることができます。"
2919
2920 #. type: Plain text
2921 #: src/doc/tutorial.md:1735
2922 msgid "~~~~ let mut max = 0; [1, 2, 3].map(|x| if *x > max { max = *x }); ~~~~"
2923 msgstr ""
2924 "~~~~\n"
2925 "let mut max = 0;\n"
2926 "[1, 2, 3].map(|x| if *x > max { max = *x });\n"
2927 "~~~~"
2928
2929 #. type: Plain text
2930 #: src/doc/tutorial.md:1744
2931 msgid ""
2932 "Stack closures are very efficient because their environment is allocated on "
2933 "the call stack and refers by pointer to captured locals. To ensure that "
2934 "stack closures never outlive the local variables to which they refer, stack "
2935 "closures are not first-class. That is, they can only be used in argument "
2936 "position; they cannot be stored in data structures or returned from "
2937 "functions. Despite these limitations, stack closures are used pervasively in "
2938 "Rust code."
2939 msgstr ""
2940 "スタッククロージャは、閉じ込める環境はコールスタック上に獲得され、ローカル変"
2941 "数をポインタで参照するため、非常に効率的です。スタッククロージャが参照してい"
2942 "るローカル変数よりも長生きしないことを保証するため、スタッククロージャは第一"
2943 "級の値ではありません。すなわち、スタッククロージャは引数としてしか使うことが"
2944 "できず、データ構造や関数の戻り値となることはありません。この制限にも関わら"
2945 "ず、スタッククロージャは Rust のコードのあちこちに登場します。"
2946
2947 #. type: Plain text
2948 #: src/doc/tutorial.md:1746
2949 msgid "## Owned closures"
2950 msgstr "## 所有クロージャ"
2951
2952 #. type: Plain text
2953 #: src/doc/tutorial.md:1753
2954 msgid ""
2955 "Owned closures, written `proc`, hold on to things that can safely be sent "
2956 "between processes. They copy the values they close over, much like managed "
2957 "closures, but they also own them: that is, no other code can access them. "
2958 "Owned closures are used in concurrent code, particularly for spawning [tasks]"
2959 "[tasks]."
2960 msgstr ""
2961 "`~` `proc` で書き表される所有クロージャは安全にプロセス間で送信することができ"
2962 "ます。所有クローじゃはマネージドクロージャと全く同じように閉じ込める値をコ"
2963 "ピーしますが、値を所有します。つまり、他のコードは閉じ込められた値にアクセス"
2964 "できなくなります。所有クロージャは並列プログラム、特に [タスク][tasks] 生成で"
2965 "利用されます。"
2966
2967 #. type: Plain text
2968 #: src/doc/tutorial.md:1755
2969 msgid "## Closure compatibility"
2970 msgstr "## クロージャの互換性"
2971
2972 #. type: Plain text
2973 #: src/doc/tutorial.md:1762
2974 msgid ""
2975 "Rust closures have a convenient subtyping property: you can pass any kind of "
2976 "closure (as long as the arguments and return types match) to functions that "
2977 "expect a `||`. Thus, when writing a higher-order function that only calls "
2978 "its function argument, and does nothing else with it, you should almost "
2979 "always declare the type of that argument as `||`. That way, callers may pass "
2980 "any kind of closure."
2981 msgstr ""
2982 "Rust のクロージャは型の派生 (subtyping) という便利な性質を持っています。この"
2983 "性質により、`||` 型を期待する関数には (引数と戻り値の型が一致する限り) 任意の"
2984 "種類のクロージャを渡すことができます。したがって、引数で渡された関数について"
2985 "は呼び出すだけで他に何もしない高階関数を書くときには、ほぼすべてのケースで引"
2986 "数の型を `||` と宣言するべきです。そうすることで、呼び出し元は任意の種類のク"
2987 "ロージャを渡すことができるよになります。"
2988
2989 #. type: Plain text
2990 #: src/doc/tutorial.md:1770
2991 msgid ""
2992 "~~~~ fn call_twice(f: ||) { f(); f(); } let closure = || { \"I'm a closure, "
2993 "and it doesn't matter what type I am\"; }; fn function() { \"I'm a normal "
2994 "function\"; } call_twice(closure); call_twice(function); ~~~~"
2995 msgstr ""
2996 "~~~~\n"
2997 "fn call_twice(f: ||) { f(); f(); }\n"
2998 "let closure = || { \"I'm a closure, and it doesn't matter what type I am"
2999 "\"; };\n"
3000 "fn function() { \"I'm a normal function\"; }\n"
3001 "call_twice(closure);\n"
3002 "call_twice(function);\n"
3003 "~~~~"
3004
3005 #. type: Plain text
3006 #: src/doc/tutorial.md:1774
3007 msgid ""
3008 "> *Note:* Both the syntax and the semantics will be changing > in small "
3009 "ways. At the moment they can be unsound in some > scenarios, particularly "
3010 "with non-copyable types."
3011 msgstr ""
3012 "> *注意* コードの文法と意味は将来的に変更されるかもしれません。現時点では"
3013 "いくつかの状況、特にコピーできない型が関連するケースにおいて望ましくない振る"
3014 "舞いが起こされる場合があります。"
3015
3016 #. type: Plain text
3017 #: src/doc/tutorial.md:1776
3018 msgid "## Do syntax"
3019 msgstr "## do 構文"
3020
3021 #. type: Plain text
3022 #: src/doc/tutorial.md:1779
3023 #, fuzzy
3024 #| msgid ""
3025 #| "The `do` expression provides a way to treat higher-order functions "
3026 #| "(functions that take closures as arguments) as control structures."
3027 msgid ""
3028 "The `do` expression makes it easier to call functions that take procedures "
3029 "as arguments."
3030 msgstr ""
3031 "`do` 式は高階関数 (クロージャを引数にとる関数) を制御構造のように取り扱う方法"
3032 "を提供します。"
3033
3034 #. type: Plain text
3035 #: src/doc/tutorial.md:1791
3036 msgid ""
3037 "As a caller, if we use a closure to provide the final operator argument, we "
3038 "can write it in a way that has a pleasant, block-like structure."
3039 msgstr ""
3040 "最後の引数にクロージャをとる関数を呼び出す場合、ブロック構造を持つかのように"
3041 "コードを書くことが可能です。"
3042
3043 #. type: Plain text
3044 #: src/doc/tutorial.md:1813
3045 msgid ""
3046 "If you want to see the output of `debug!` statements, you will need to turn "
3047 "on `debug!` logging.  To enable `debug!` logging, set the RUST_LOG "
3048 "environment variable to the name of your crate, which, for a file named `foo."
3049 "rs`, will be `foo` (e.g., with bash, `export RUST_LOG=foo`)."
3050 msgstr ""
3051 "`debug!` ステートメントの出力を見たい場合、`debug!` によるロギングを有効にす"
3052 "る必要があるでしょう。`debug!` によるロギングを有効にするためには、 RUST_LOG "
3053 "環境変数をクレートの名前に設定する必要があります (例えば、bash の場合、 "
3054 "`export RUST_LOG=foo` を実行する)。 `foo.rs` というファイルの場合、クレート名"
3055 "は `foo` になります。"
3056
3057 #. type: Plain text
3058 #: src/doc/tutorial.md:1815
3059 msgid "# Methods"
3060 msgstr "# メソッド"
3061
3062 #. type: Plain text
3063 #: src/doc/tutorial.md:1821
3064 msgid ""
3065 "Methods are like functions except that they always begin with a special "
3066 "argument, called `self`, which has the type of the method's receiver. The "
3067 "`self` argument is like `this` in C++ and many other languages.  Methods are "
3068 "called with dot notation, as in `my_vec.len()`."
3069 msgstr ""
3070 "メソッドは、`self` という、メソッドのレシーバと同じ型の特別な引数を第一引数と"
3071 "してとる関数のようなものです。`self` は、 C++ や他の言語の `this` のようなも"
3072 "のです。メソッドはドット記法を浸かって `my_vec.len()` のように呼び出します。"
3073
3074 #. type: Plain text
3075 #: src/doc/tutorial.md:1825
3076 msgid ""
3077 "_Implementations_, written with the `impl` keyword, can define methods on "
3078 "most Rust types, including structs and enums.  As an example, let's define a "
3079 "`draw` method on our `Shape` enum."
3080 msgstr ""
3081 "`impl` キーワードを使って記述される __実装__ (_implementation_) により、構造"
3082 "体や列挙型を含むほとんどの Rust の型に対してメソッドを定義することができま"
3083 "す。例のように、 `draw` メソッドを `Shape` 列挙型に定義してみましょう。"
3084
3085 #. type: Plain text
3086 #: src/doc/tutorial.md:1833
3087 #, fuzzy, no-wrap
3088 #| msgid "~~~~ {.ignore} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
3089 msgid ""
3090 "~~~\n"
3091 "# fn draw_circle(p: Point, f: f64) { }\n"
3092 "# fn draw_rectangle(p: Point, p: Point) { }\n"
3093 "struct Point {\n"
3094 "    x: f64,\n"
3095 "    y: f64\n"
3096 "}\n"
3097 msgstr ""
3098 "~~~~ {.ignore}\n"
3099 "# struct Point { x: f64, y: f64 }\n"
3100 "let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
3101 "let origin = Point { x: 0.0, y: 0.0 };"
3102
3103 #. type: Plain text
3104 #: src/doc/tutorial.md:1851
3105 #, fuzzy
3106 #| msgid "let s = Circle(Point { x: 1f, y: 2f }, 3f); s.draw(); ~~~"
3107 msgid "let s = Circle(Point { x: 1.0, y: 2.0 }, 3.0); s.draw(); ~~~"
3108 msgstr ""
3109 "let s = Circle(Point { x: 1f, y: 2f }, 3f);\n"
3110 "s.draw();\n"
3111 "~~~"
3112
3113 #. type: Plain text
3114 #: src/doc/tutorial.md:1855
3115 msgid ""
3116 "This defines an _implementation_ for `Shape` containing a single method, "
3117 "`draw`. In most respects the `draw` method is defined like any other "
3118 "function, except for the name `self`."
3119 msgstr ""
3120 "この例では、 `Shape` に1つのメソッド `draw` をもつ __実装__ を定義していま"
3121 "す。`draw` メソッドは、`self` という名前を除くほとんどの面で他の関数と同じよ"
3122 "うに定義されます。"
3123
3124 #. type: Plain text
3125 #: src/doc/tutorial.md:1860
3126 msgid ""
3127 "The type of `self` is the type on which the method is implemented, or a "
3128 "pointer thereof. As an argument it is written either `self`, `&self`, "
3129 "`@self`, or `~self`.  A caller must in turn have a compatible pointer type "
3130 "to call the method."
3131 msgstr ""
3132 "`self` の型は、メソッドが実装されている型か、それらのポインタである。引数とし"
3133 "ては、 `self`, `&self`, `@self` または `~self` と記述されます。呼び出し側も同"
3134 "様、メソッドを呼び出すための互換性のあるポインタ型をもつ必要があります。"
3135
3136 #. type: Plain text
3137 #: src/doc/tutorial.md:1875
3138 #, fuzzy, no-wrap
3139 #| msgid ""
3140 #| "~~~\n"
3141 #| "# fn draw_circle(p: Point, f: f64) { }\n"
3142 #| "# fn draw_rectangle(p: Point, p: Point) { }\n"
3143 #| "# struct Point { x: f64, y: f64 }\n"
3144 #| "# enum Shape {\n"
3145 #| "#     Circle(Point, f64),\n"
3146 #| "#     Rectangle(Point, Point)\n"
3147 #| "# }\n"
3148 #| "# impl Shape {\n"
3149 #| "#    fn draw_borrowed(&self) { ... }\n"
3150 #| "#    fn draw_managed(@self) { ... }\n"
3151 #| "#    fn draw_owned(~self) { ... }\n"
3152 #| "#    fn draw_value(self) { ... }\n"
3153 #| "# }\n"
3154 #| "# let s = Circle(Point { x: 1f, y: 2f }, 3f);\n"
3155 #| "// As with typical function arguments, managed and owned pointers\n"
3156 #| "// are automatically converted to borrowed pointers\n"
3157 msgid ""
3158 "~~~\n"
3159 "# fn draw_circle(p: Point, f: f64) { }\n"
3160 "# fn draw_rectangle(p: Point, p: Point) { }\n"
3161 "# struct Point { x: f64, y: f64 }\n"
3162 "# enum Shape {\n"
3163 "#     Circle(Point, f64),\n"
3164 "#     Rectangle(Point, Point)\n"
3165 "# }\n"
3166 "impl Shape {\n"
3167 "    fn draw_reference(&self) { ... }\n"
3168 "    fn draw_managed(@self) { ... }\n"
3169 "    fn draw_owned(~self) { ... }\n"
3170 "    fn draw_value(self) { ... }\n"
3171 "}\n"
3172 msgstr ""
3173 "~~~\n"
3174 "# fn draw_circle(p: Point, f: f64) { }\n"
3175 "# fn draw_rectangle(p: Point, p: Point) { }\n"
3176 "# struct Point { x: f64, y: f64 }\n"
3177 "# enum Shape {\n"
3178 "#     Circle(Point, f64),\n"
3179 "#     Rectangle(Point, Point)\n"
3180 "# }\n"
3181 "# impl Shape {\n"
3182 "#    fn draw_borrowed(&self) { ... }\n"
3183 "#    fn draw_managed(@self) { ... }\n"
3184 "#    fn draw_owned(~self) { ... }\n"
3185 "#    fn draw_value(self) { ... }\n"
3186 "# }\n"
3187 "# let s = Circle(Point { x: 1f, y: 2f }, 3f);\n"
3188 "// 関数の引数と同様、マネージドポインタと所有ポインタは、\n"
3189 "// 自動的に借用ポインタに変換される\n"
3190
3191 #. type: Plain text
3192 #: src/doc/tutorial.md:1877
3193 #, fuzzy
3194 #| msgid "let s = Circle(Point { x: 1f, y: 2f }, 3f); s.draw(); ~~~"
3195 msgid "let s = Circle(Point { x: 1.0, y: 2.0 }, 3.0);"
3196 msgstr ""
3197 "let s = Circle(Point { x: 1f, y: 2f }, 3f);\n"
3198 "s.draw();\n"
3199 "~~~"
3200
3201 #. type: Plain text
3202 #: src/doc/tutorial.md:1883
3203 #, fuzzy
3204 #| msgid ""
3205 #| "(@s).draw_managed(); (~s).draw_owned(); (&s).draw_borrowed(); s."
3206 #| "draw_value(); ~~~"
3207 msgid ""
3208 "(@s).draw_managed(); (~s).draw_owned(); (&s).draw_reference(); s."
3209 "draw_value(); ~~~"
3210 msgstr ""
3211 "(@s).draw_managed();\n"
3212 "(~s).draw_owned();\n"
3213 "(&s).draw_borrowed();\n"
3214 "s.draw_value();\n"
3215 "~~~"
3216
3217 #. type: Plain text
3218 #: src/doc/tutorial.md:1887
3219 #, fuzzy
3220 #| msgid ""
3221 #| "Methods typically take a borrowed pointer self type, so the compiler will "
3222 #| "go to great lengths to convert a callee to a borrowed pointer."
3223 msgid ""
3224 "Methods typically take a reference self type, so the compiler will go to "
3225 "great lengths to convert a callee to a reference."
3226 msgstr ""
3227 "多くのメソッドは、借用ポインタの self 型を持つので、コンパイラは呼び出し先を"
3228 "借用ポインタに変換するためあらゆる手段を講じます。"
3229
3230 #. type: Plain text
3231 #: src/doc/tutorial.md:1905
3232 #, fuzzy, no-wrap
3233 #| msgid ""
3234 #| "~~~\n"
3235 #| "# fn draw_circle(p: Point, f: f64) { }\n"
3236 #| "# fn draw_rectangle(p: Point, p: Point) { }\n"
3237 #| "# struct Point { x: f64, y: f64 }\n"
3238 #| "# enum Shape {\n"
3239 #| "#     Circle(Point, f64),\n"
3240 #| "#     Rectangle(Point, Point)\n"
3241 #| "# }\n"
3242 #| "# impl Shape {\n"
3243 #| "#    fn draw_borrowed(&self) { ... }\n"
3244 #| "#    fn draw_managed(@self) { ... }\n"
3245 #| "#    fn draw_owned(~self) { ... }\n"
3246 #| "#    fn draw_value(self) { ... }\n"
3247 #| "# }\n"
3248 #| "# let s = Circle(Point { x: 1f, y: 2f }, 3f);\n"
3249 #| "// As with typical function arguments, managed and owned pointers\n"
3250 #| "// are automatically converted to borrowed pointers\n"
3251 msgid ""
3252 "~~~\n"
3253 "# fn draw_circle(p: Point, f: f64) { }\n"
3254 "# fn draw_rectangle(p: Point, p: Point) { }\n"
3255 "# struct Point { x: f64, y: f64 }\n"
3256 "# enum Shape {\n"
3257 "#     Circle(Point, f64),\n"
3258 "#     Rectangle(Point, Point)\n"
3259 "# }\n"
3260 "# impl Shape {\n"
3261 "#    fn draw_reference(&self) { ... }\n"
3262 "#    fn draw_managed(@self) { ... }\n"
3263 "#    fn draw_owned(~self) { ... }\n"
3264 "#    fn draw_value(self) { ... }\n"
3265 "# }\n"
3266 "# let s = Circle(Point { x: 1.0, y: 2.0 }, 3.0);\n"
3267 "// As with typical function arguments, managed and owned pointers\n"
3268 "// are automatically converted to references\n"
3269 msgstr ""
3270 "~~~\n"
3271 "# fn draw_circle(p: Point, f: f64) { }\n"
3272 "# fn draw_rectangle(p: Point, p: Point) { }\n"
3273 "# struct Point { x: f64, y: f64 }\n"
3274 "# enum Shape {\n"
3275 "#     Circle(Point, f64),\n"
3276 "#     Rectangle(Point, Point)\n"
3277 "# }\n"
3278 "# impl Shape {\n"
3279 "#    fn draw_borrowed(&self) { ... }\n"
3280 "#    fn draw_managed(@self) { ... }\n"
3281 "#    fn draw_owned(~self) { ... }\n"
3282 "#    fn draw_value(self) { ... }\n"
3283 "# }\n"
3284 "# let s = Circle(Point { x: 1f, y: 2f }, 3f);\n"
3285 "// 関数の引数と同様、マネージドポインタと所有ポインタは、\n"
3286 "// 自動的に借用ポインタに変換される\n"
3287
3288 #. type: Plain text
3289 #: src/doc/tutorial.md:1908
3290 #, fuzzy
3291 #| msgid "(@s).draw_borrowed(); (~s).draw_borrowed();"
3292 msgid "(@s).draw_reference(); (~s).draw_reference();"
3293 msgstr ""
3294 "(@s).draw_borrowed();\n"
3295 "(~s).draw_borrowed();"
3296
3297 #. type: Plain text
3298 #: src/doc/tutorial.md:1912
3299 #, fuzzy
3300 #| msgid ""
3301 #| "// Unlike typical function arguments, the self value will // "
3302 #| "automatically be referenced ...  s.draw_borrowed();"
3303 msgid ""
3304 "// Unlike typical function arguments, the self value will // automatically "
3305 "be referenced ...  s.draw_reference();"
3306 msgstr ""
3307 "// 関数の引数とは異なり、 self の値は自動的にリファレンスされたり、 ...\n"
3308 "s.draw_borrowed();"
3309
3310 #. type: Plain text
3311 #: src/doc/tutorial.md:1915
3312 #, fuzzy
3313 #| msgid "// ... and dereferenced (& &s).draw_borrowed();"
3314 msgid "// ... and dereferenced (& &s).draw_reference();"
3315 msgstr ""
3316 "// ... デリファレンスされたり、\n"
3317 "(& &s).draw_borrowed();"
3318
3319 #. type: Plain text
3320 #: src/doc/tutorial.md:1919
3321 #, fuzzy
3322 #| msgid "// ... and dereferenced and borrowed (&@~s).draw_borrowed(); ~~~"
3323 msgid "// ... and dereferenced and borrowed (&@~s).draw_reference(); ~~~"
3324 msgstr ""
3325 "// ... デリファレンス後借用されたりします\n"
3326 "(&@~s).draw_borrowed();\n"
3327 "~~~"
3328
3329 #. type: Plain text
3330 #: src/doc/tutorial.md:1923
3331 msgid ""
3332 "Implementations may also define standalone (sometimes called \"static\")  "
3333 "methods. The absence of a `self` parameter distinguishes such methods.  "
3334 "These methods are the preferred way to define constructor functions."
3335 msgstr ""
3336 "実装では、スタンドアロンなメソッド (「静的 (static)」メソッドと呼ばれる場合も"
3337 "あります)を定義することも可能です。引数に `self` をつけない場合、スタンドアロ"
3338 "ンなメソッドとなります。コンストラクタ関数は、スタンドアロンなメソッドとして"
3339 "定義することが推奨されています。"
3340
3341 #. type: Plain text
3342 #: src/doc/tutorial.md:1932
3343 msgid ""
3344 "To call such a method, just prefix it with the type name and a double colon:"
3345 msgstr ""
3346 "メソッド名の前に型名と2つのコロンを付けることで、スタンドアロンメソッドは呼び"
3347 "出せます。"
3348
3349 #. type: Plain text
3350 #: src/doc/tutorial.md:1943
3351 msgid "# Generics"
3352 msgstr "# ジェネリクス"
3353
3354 #. type: Plain text
3355 #: src/doc/tutorial.md:1951
3356 msgid ""
3357 "Throughout this tutorial, we've been defining functions that act only on "
3358 "specific data types. With type parameters we can also define functions whose "
3359 "arguments have generic types, and which can be invoked with a variety of "
3360 "types. Consider a generic `map` function, which takes a function `function` "
3361 "and a vector `vector` and returns a new vector consisting of the result of "
3362 "applying `function` to each element of `vector`:"
3363 msgstr ""
3364 "このチュートリアルでは、特定のデータ型のみに対して動作する関数を定義してきま"
3365 "した。型パラメータを用いるとジェネリックな型を引数にとり、様々な型で呼び出す"
3366 "ことの可能な関数を定義できます。関数 `function` とベクタ `vector` を引数にと"
3367 "り、`function` を`vector` の各要素に適用した結果からなる新たなベクタを返す、"
3368 "`map` というジェネリック関数について考えます。"
3369
3370 #. type: Plain text
3371 #: src/doc/tutorial.md:1966
3372 msgid ""
3373 "When defined with type parameters, as denoted by `<T, U>`, this function can "
3374 "be applied to any type of vector, as long as the type of `function`'s "
3375 "argument and the type of the vector's contents agree with each other."
3376 msgstr ""
3377 "上記例で `<T, U>` と示されているように、型パラメータとともに関数を定義するこ"
3378 "とで、`function` の引数の型と`vectror` の要素の型が一致する場合に限りますが、"
3379 "任意の型のベクタを引数として渡すことが可能になります。"
3380
3381 #. type: Plain text
3382 #: src/doc/tutorial.md:1976
3383 msgid ""
3384 "Inside a generic function, the names of the type parameters (capitalized by "
3385 "convention) stand for opaque types. All you can do with instances of these "
3386 "types is pass them around: you can't apply any operations to them or pattern-"
3387 "match on them. Note that instances of generic types are often passed by "
3388 "pointer. For example, the parameter `function()` is supplied with a pointer "
3389 "to a value of type `T` and not a value of type `T` itself. This ensures that "
3390 "the function works with the broadest set of types possible, since some types "
3391 "are expensive or illegal to copy and pass by value."
3392 msgstr ""
3393 "ジェネリック関数の内部では、型パラメータの名前 (慣例的に大文字で表されます) "
3394 "は不透明型 (opaque type) を意味します。これらの型のインスタンスに対しては、他"
3395 "の関数に渡すことだけが可能で、演算子を適用したり、パターンマッチすることはで"
3396 "きません。ジェネリック型のインスタンスは、ポインタにより渡されることもあるこ"
3397 "とに注意してください。例えば、 `function()` パラメータが `T` 型自身の値ではな"
3398 "く `T` 型の値へのポインタとして渡されるということです。いくつかの型は、値をコ"
3399 "ピーするコストが高かったり、コピーが禁じられていたりするので、ポインタ渡しに"
3400 "することで、関数の引数としてとることのできる型の範囲が広がります。"
3401
3402 #. type: Plain text
3403 #: src/doc/tutorial.md:1978
3404 msgid ""
3405 "Generic `type`, `struct`, and `enum` declarations follow the same pattern:"
3406 msgstr ""
3407 "ジェネリックな型、構造体、および列挙型の宣言は、同じパターンに従います。"
3408
3409 #. type: Plain text
3410 #: src/doc/tutorial.md:1982
3411 msgid "~~~~ use std::hashmap::HashMap; type Set<T> = HashMap<T, ()>;"
3412 msgstr ""
3413 "~~~~\n"
3414 "use std::hashmap::HashMap;\n"
3415 "type Set<T> = HashMap<T, ()>;"
3416
3417 #. type: Plain text
3418 #: src/doc/tutorial.md:1995
3419 msgid ""
3420 "These declarations can be instantiated to valid types like `Set<int>`, "
3421 "`Stack<int>`, and `Option<int>`."
3422 msgstr ""
3423 "これらの宣言により、 `Set<int>` や `Stack<int>`、 `Option<int>` のような正当"
3424 "な型を生成することができます。"
3425
3426 #. type: Plain text
3427 #: src/doc/tutorial.md:2001
3428 msgid ""
3429 "The last type in that example, `Option`, appears frequently in Rust code.  "
3430 "Because Rust does not have null pointers (except in unsafe code), we need "
3431 "another way to write a function whose result isn't defined on every possible "
3432 "combination of arguments of the appropriate types. The usual way is to write "
3433 "a function that returns `Option<T>` instead of `T`."
3434 msgstr ""
3435 "最後の例の `Option` 型は、Rust のコード中に頻繁に現れます。Rust には null ポ"
3436 "インタが存在しない (unsafe なコードを除く) ため、引数の組み合わせがとりうるす"
3437 "べての値に対し結果が定義されないような関数を記述するための別の方法が必要で"
3438 "す。このような場合には、 `T` 型ではなく `Option<T>` 型を返すよう関数を定義す"
3439 "ることが一般的です。"
3440
3441 #. type: Plain text
3442 #: src/doc/tutorial.md:2020
3443 msgid ""
3444 "The Rust compiler compiles generic functions very efficiently by "
3445 "*monomorphizing* them. *Monomorphization* is a fancy name for a simple idea: "
3446 "generate a separate copy of each generic function at each call site, a copy "
3447 "that is specialized to the argument types and can thus be optimized "
3448 "specifically for them. In this respect, Rust's generics have similar "
3449 "performance characteristics to C++ templates."
3450 msgstr ""
3451 "Rust のコンパイラは、ジェネリック関数を *monomorphizing* することで効率的にコ"
3452 "ンパイルします。*monomorphization* という名前は大げさに聞こえますが、考え方は"
3453 "単純です。ジェネリック関数のコピーを関数の呼び出し箇所に別々に生成し、引数の"
3454 "型により特殊化された各コピーは、それぞれの特性に応じて最適化が施されます。こ"
3455 "の点において、Rust のジェネリクスは C++ のテンプレートと似たパフォーマンス上"
3456 "の特性を持ちます。"
3457
3458 #. type: Plain text
3459 #: src/doc/tutorial.md:2022
3460 msgid "## Traits"
3461 msgstr "## トレイト"
3462
3463 #. type: Plain text
3464 #: src/doc/tutorial.md:2034
3465 #, fuzzy
3466 #| msgid ""
3467 #| "Within a generic function the operations available on generic types are "
3468 #| "very limited. After all, since the function doesn't know what types it is "
3469 #| "operating on, it can't safely modify or query their values. This is where "
3470 #| "_traits_ come into play. Traits are Rust's most powerful tool for writing "
3471 #| "polymorphic code. Java developers will see them as similar to Java "
3472 #| "interfaces, and Haskellers will notice their similarities to type "
3473 #| "classes. Rust's traits are a form of *bounded polymorphism*: a trait is a "
3474 #| "way of limiting the set of possible types that a type parameter could "
3475 #| "refer to."
3476 msgid ""
3477 "Within a generic function -- that is, a function parameterized by a type "
3478 "parameter, say, `T` -- the operations we can do on arguments of type `T` are "
3479 "quite limited.  After all, since we don't know what type `T` will be "
3480 "instantiated with, we can't safely modify or query values of type `T`.  This "
3481 "is where _traits_ come into play. Traits are Rust's most powerful tool for "
3482 "writing polymorphic code. Java developers will see them as similar to Java "
3483 "interfaces, and Haskellers will notice their similarities to type classes. "
3484 "Rust's traits give us a way to express *bounded polymorphism*: by limiting "
3485 "the set of possible types that a type parameter could refer to, they expand "
3486 "the number of operations we can safely perform on arguments of that type."
3487 msgstr ""
3488 "ジェネリック関数の内部では、ジェネリック型に対して非常に限られた操作しか行え"
3489 "ません。つまるところ、ジェネリック関数は操作の対象とする型が何なのか知らない"
3490 "ため、対象の値を安全に変更・参照することができません。__トレイト__ (_trait_) "
3491 "の出番です。トレイトは Rust でポリモーフィックなコードを書くための最も強力な"
3492 "ツールです。Java 開発者にとってトレイトは Java のインターフェースのように見え"
3493 "ますし、Haskeller は型クラスとの類似点に気づくでしょう。Rust のトレイトは **"
3494 "有界ポリモーフィズム** (*bounded polymorphism*) の形式をとります。トレイトに"
3495 "より、型パラメータが示す得る型の集合を限定することができます。"
3496
3497 #. type: Plain text
3498 #: src/doc/tutorial.md:2041
3499 #, fuzzy
3500 #| msgid ""
3501 #| "As motivation, let us consider copying in Rust.  The `clone` method is "
3502 #| "not defined for all Rust types.  One reason is user-defined destructors: "
3503 #| "copying a type that has a destructor could result in the destructor "
3504 #| "running multiple times.  Therefore, types with destructors cannot be "
3505 #| "copied unless you explicitly implement `Clone` for them."
3506 msgid ""
3507 "As motivation, let us consider copying of values in Rust.  The `clone` "
3508 "method is not defined for values of every type.  One reason is user-defined "
3509 "destructors: copying a value of a type that has a destructor could result in "
3510 "the destructor running multiple times.  Therefore, values of types that have "
3511 "destructors cannot be copied unless we explicitly implement `clone` for them."
3512 msgstr ""
3513 "トレイト導入の動機となる例として、Rust でのコピーについて考えます。`clone` メ"
3514 "ソッドはすべての Rust の型に対して定義されていません。定義されていない理由の"
3515 "一つとして、ユーザ定義のデストラクタの存在が挙げられます。デストラクタを持つ"
3516 "型をコピーすることで、デストラクタが複数回実行されるという事態を招いてしまう"
3517 "かもしれません。そのため、明示的に `Clone` を実装していない型を除き、デストラ"
3518 "クタをもつ型をコピーすることはできません。"
3519
3520 #. type: Plain text
3521 #: src/doc/tutorial.md:2047
3522 #, fuzzy
3523 #| msgid ""
3524 #| "This complicates handling of generic functions.  If you have a type "
3525 #| "parameter `T`, can you copy values of that type? In Rust, you can't, and "
3526 #| "if you try to run the following code the compiler will complain."
3527 msgid ""
3528 "This complicates handling of generic functions.  If we have a function with "
3529 "a type parameter `T`, can we copy values of type `T` inside that function? "
3530 "In Rust, we can't, and if we try to run the following code the compiler will "
3531 "complain."
3532 msgstr ""
3533 "このことはジェネリック関数の扱い方を複雑にします。型パラメータ `T` が存在した"
3534 "として、この型の値をコピーすることができるでしょうか?Rust では、コピーするこ"
3535 "とはできません。以下のコードを実行しようとしてもコンパイラが文句を言うでしょ"
3536 "う。"
3537
3538 #. type: Plain text
3539 #: src/doc/tutorial.md:2054
3540 #, no-wrap
3541 msgid ""
3542 "~~~~ {.ignore}\n"
3543 "// This does not compile\n"
3544 "fn head_bad<T>(v: &[T]) -> T {\n"
3545 "    v[0] // error: copying a non-copyable value\n"
3546 "}\n"
3547 "~~~~\n"
3548 msgstr ""
3549 "~~~~ {.ignore}\n"
3550 "// このコードはコンパイルできない\n"
3551 "fn head_bad<T>(v: &[T]) -> T {\n"
3552 "    v[0] // error: copying a non-copyable value\n"
3553 "}\n"
3554 "~~~~\n"
3555
3556 #. type: Plain text
3557 #: src/doc/tutorial.md:2060
3558 #, fuzzy
3559 #| msgid ""
3560 #| "However, we can tell the compiler that the `head` function is only for "
3561 #| "copyable types: that is, those that implement the `Clone` trait.  In that "
3562 #| "case, we can explicitly create a second copy of the value we are "
3563 #| "returning using the `clone` keyword:"
3564 msgid ""
3565 "However, we can tell the compiler that the `head` function is only for "
3566 "copyable types.  In Rust, copyable types are those that _implement the "
3567 "`Clone` trait_.  We can then explicitly create a second copy of the value we "
3568 "are returning by calling the `clone` method:"
3569 msgstr ""
3570 "`head` 関数はコピー可能な型、つまり `Clone` トレイトを実装している型だけを対"
3571 "象にしていることをコンパイラに教えることはできます。この場合、`clone` メソッ"
3572 "ドを使うことで、値のコピーを明示的に作成し、戻り値として返すことができます。"
3573
3574 #. type: Plain text
3575 #: src/doc/tutorial.md:2067
3576 #, no-wrap
3577 msgid ""
3578 "~~~~\n"
3579 "// This does\n"
3580 "fn head<T: Clone>(v: &[T]) -> T {\n"
3581 "    v[0].clone()\n"
3582 "}\n"
3583 "~~~~\n"
3584 msgstr ""
3585 "~~~~\n"
3586 "// このコードはコンパイルできる\n"
3587 "fn head<T: Clone>(v: &[T]) -> T {\n"
3588 "    v[0].clone()\n"
3589 "}\n"
3590 "~~~~\n"
3591
3592 #. type: Plain text
3593 #: src/doc/tutorial.md:2077
3594 #, fuzzy
3595 #| msgid ""
3596 #| "This says that we can call `head` on any type `T` as long as that type "
3597 #| "implements the `Clone` trait.  When instantiating a generic function, you "
3598 #| "can only instantiate it with types that implement the correct trait, so "
3599 #| "you could not apply `head` to a type that does not implement `Clone`."
3600 msgid ""
3601 "The bounded type parameter `T: Clone` says that `head` can be called on an "
3602 "argument of type `&[T]` for any `T`, so long as there is an implementation "
3603 "of the `Clone` trait for `T`.  When instantiating a generic function, we can "
3604 "only instantiate it with types that implement the correct trait, so we could "
3605 "not apply `head` to a vector whose elements are of some type that does not "
3606 "implement `Clone`."
3607 msgstr ""
3608 "このことは、`Clone` トレイトを実装している任意の型 `T` について、 `head` 関数"
3609 "を呼び出すことができることを示しています。ジェネリック関数を実体化する場合、"
3610 "正しいトレイトを実装した型を用いた場合のみ実体化できます。つまり、`Clone` ト"
3611 "レイトを実装していない型に対して `head` を呼び出すことはできません。"
3612
3613 #. type: Plain text
3614 #: src/doc/tutorial.md:2082
3615 #, fuzzy
3616 #| msgid ""
3617 #| "While most traits can be defined and implemented by user code, two traits "
3618 #| "are automatically derived and implemented for all applicable types by the "
3619 #| "compiler, and may not be overridden:"
3620 msgid ""
3621 "While most traits can be defined and implemented by user code, three traits "
3622 "are automatically derived and implemented for all applicable types by the "
3623 "compiler, and may not be overridden:"
3624 msgstr ""
3625 "ほとんどのトレイトはユーザコードにより定義・実装できますが、2つのトレイトはコ"
3626 "ンパイラにより自動的に導出され、適用可能なすべての型に対し自動的に実装され、"
3627 "上書きすることはできません。"
3628
3629 #. type: Plain text
3630 #: src/doc/tutorial.md:2086
3631 #, fuzzy, no-wrap
3632 #| msgid ""
3633 #| "* `Send` - Sendable types.\n"
3634 #| "Types are sendable\n"
3635 #| "unless they contain managed boxes, managed closures, or borrowed pointers.\n"
3636 msgid ""
3637 "* `Send` - Sendable types.\n"
3638 "Types are sendable\n"
3639 "unless they contain managed boxes, managed closures, or references.\n"
3640 msgstr ""
3641 "* `Send` - 送信可能な型。\n"
3642 "マネージドボックスやマネージドクロージャ、借用ポインタを含まない場合、型は送信可能である。"
3643
3644 #. type: Plain text
3645 #: src/doc/tutorial.md:2090
3646 #, fuzzy, no-wrap
3647 #| msgid ""
3648 #| "* `Freeze` - Constant (immutable) types.\n"
3649 #| "These are types that do not contain anything intrinsically mutable.\n"
3650 #| "Intrinsically mutable values include `@mut`\n"
3651 #| "and `Cell` in the standard library.\n"
3652 msgid ""
3653 "* `Freeze` - Constant (immutable) types.\n"
3654 "These are types that do not contain anything intrinsically mutable.\n"
3655 "Intrinsically mutable values include `Cell` in the standard library.\n"
3656 msgstr ""
3657 "* `Freeze` - 定数 (イミュータブル) 型。\n"
3658 "本質的に変更可能な値を含まない型のことです。本質的に変更可能な値には、`@mut` や標準ライブラリで定義されている `Cell` が含まれます。\n"
3659
3660 #. type: Plain text
3661 #: src/doc/tutorial.md:2099
3662 msgid ""
3663 "> *Note:* These two traits were referred to as 'kinds' in earlier > "
3664 "iterations of the language, and often still are."
3665 msgstr ""
3666 "> *注意* これら2つのトレイトは、以前は 「種」 (kind) と呼ばれており、現在"
3667 "でもそう呼ばれる場合があります。"
3668
3669 #. type: Plain text
3670 #: src/doc/tutorial.md:2105
3671 #, fuzzy
3672 #| msgid ""
3673 #| "Additionally, the `Drop` trait is used to define destructors. This trait "
3674 #| "defines one method called `drop`, which is automatically called when a "
3675 #| "value of the type that implements this trait is destroyed, either because "
3676 #| "the value went out of scope or because the garbage collector reclaimed it."
3677 msgid ""
3678 "Additionally, the `Drop` trait is used to define destructors. This trait "
3679 "provides one method called `drop`, which is automatically called when a "
3680 "value of the type that implements this trait is destroyed, either because "
3681 "the value went out of scope or because the garbage collector reclaimed it."
3682 msgstr ""
3683 "上記に加え、 `Drop` トレイトはデストラクタを定義するために使われます。このト"
3684 "レイトは `drop` というこのトレイトを実装した型が破壊されるタイミング(値がス"
3685 "コープの外に出たタイミングか、ガベージコレクタが回収するタイミング) で呼び出"
3686 "されるメソッドを1つ定義しています。"
3687
3688 #. type: Plain text
3689 #: src/doc/tutorial.md:2110
3690 #, fuzzy, no-wrap
3691 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
3692 msgid ""
3693 "~~~\n"
3694 "struct TimeBomb {\n"
3695 "    explosivity: uint\n"
3696 "}\n"
3697 msgstr ""
3698 "~~~~ {.ignore}\n"
3699 "// main.rs\n"
3700 "extern crate world;\n"
3701 "fn main() { println(~\"hello \" + world::explore()); }\n"
3702 "~~~~"
3703
3704 #. type: Plain text
3705 #: src/doc/tutorial.md:2122
3706 msgid ""
3707 "It is illegal to call `drop` directly. Only code inserted by the compiler "
3708 "may call it."
3709 msgstr ""
3710 "`drop` を直接呼び出すことはできません。コンパイラにより挿入されたコードのみ"
3711 "が `drop` を呼び出すことができます。"
3712
3713 #. type: Plain text
3714 #: src/doc/tutorial.md:2124
3715 msgid "## Declaring and implementing traits"
3716 msgstr "## トレイトの宣言と実装"
3717
3718 #. type: Plain text
3719 #: src/doc/tutorial.md:2129
3720 #, fuzzy
3721 #| msgid ""
3722 #| "A trait consists of a set of methods without bodies, or may be empty, as "
3723 #| "is the case with `Send` and `Freeze`.  For example, we could declare the "
3724 #| "trait `Printable` for things that can be printed to the console, with a "
3725 #| "single method:"
3726 msgid ""
3727 "At its simplest, a trait is a set of zero or more _method signatures_.  For "
3728 "example, we could declare the trait `Printable` for things that can be "
3729 "printed to the console, with a single method signature:"
3730 msgstr ""
3731 "トレイトはボディを持たないメソッドの集合から構成されるか、 `Send` や "
3732 "`Freeze` トレイトのように空の場合があります。例えば、コンソールに出力可能なも"
3733 "のを表しメソッドを1つもつ `Printable` トレイトは以下のように宣言できます。"
3734
3735 #. type: Plain text
3736 #: src/doc/tutorial.md:2135
3737 #, fuzzy, no-wrap
3738 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
3739 msgid ""
3740 "~~~~\n"
3741 "trait Printable {\n"
3742 "    fn print(&self);\n"
3743 "}\n"
3744 "~~~~\n"
3745 msgstr ""
3746 "~~~~ {.ignore}\n"
3747 "// main.rs\n"
3748 "extern crate world;\n"
3749 "fn main() { println(~\"hello \" + world::explore()); }\n"
3750 "~~~~"
3751
3752 #. type: Plain text
3753 #: src/doc/tutorial.md:2148
3754 #, fuzzy
3755 #| msgid ""
3756 #| "Traits may be implemented for specific types with [impls]. An impl that "
3757 #| "implements a trait includes the name of the trait at the start of the "
3758 #| "definition, as in the following impls of `Printable` for `int` and `StrBuf`."
3759 msgid ""
3760 "Traits may be implemented for specific types with [impls]. An impl for a "
3761 "particular trait gives an implementation of the methods that trait "
3762 "provides.  For instance, the following impls of `Printable` for `int` and "
3763 "`StrBuf` give implementations of the `print` method."
3764 msgstr ""
3765 "[impl][impls] により特定の型にトレイトを実装することができます。トレイトを実"
3766 "装する impl は、以下の `Printable` の `int` と `StrBuf` に対する実装のように、"
3767 "定義の先頭にトレイトの名前を含みます。"
3768
3769 #. type: Plain text
3770 #: src/doc/tutorial.md:2150
3771 msgid "[impls]: #methods"
3772 msgstr "[impls]: #メソッド"
3773
3774 #. type: Plain text
3775 #: src/doc/tutorial.md:2160 src/doc/tutorial.md:2206
3776 #, fuzzy, no-wrap
3777 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
3778 msgid ""
3779 "impl Printable for StrBuf {\n"
3780 "    fn print(&self) { println!(\"{}\", *self) }\n"
3781 "}\n"
3782 msgstr ""
3783 "~~~~ {.ignore}\n"
3784 "// main.rs\n"
3785 "extern crate world;\n"
3786 "fn main() { println(~\"hello \" + world::explore()); }\n"
3787 "~~~~"
3788
3789 #. type: Plain text
3790 #: src/doc/tutorial.md:2164
3791 msgid "# 1.print(); # (~\"foo\").print(); ~~~~"
3792 msgstr ""
3793 "# 1.print();\n"
3794 "# (~\"foo\").print();\n"
3795 "~~~~"
3796
3797 #. type: Plain text
3798 #: src/doc/tutorial.md:2167
3799 #, fuzzy
3800 #| msgid ""
3801 #| "Methods defined in an implementation of a trait may be called just like "
3802 #| "any other method, using dot notation, as in `1.print()`. Traits may "
3803 #| "themselves contain type parameters. A trait for generalized sequence "
3804 #| "types might look like the following:"
3805 msgid ""
3806 "Methods defined in an impl for a trait may be called just like any other "
3807 "method, using dot notation, as in `1.print()`."
3808 msgstr ""
3809 "トレイトの実装により定義されたメソッドは他のメソッドと全く同じように、ドット"
3810 "記法を用いて `1.print()` のように呼び出せます。トレイト自体に型パラメータを持"
3811 "たせることもできます。一般化されたシーケンスを表すトレイトは以下のように定義"
3812 "されるでしょう。"
3813
3814 #. type: Plain text
3815 #: src/doc/tutorial.md:2169
3816 #, fuzzy
3817 #| msgid "## Deriving implementations for traits"
3818 msgid "## Default method implementations in trait definitions"
3819 msgstr "## トレイトの実装の導出"
3820
3821 #. type: Plain text
3822 #: src/doc/tutorial.md:2185
3823 #, fuzzy, no-wrap
3824 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
3825 msgid ""
3826 "impl Printable for bool {\n"
3827 "    fn print(&self) { println!(\"{:?}\", *self) }\n"
3828 "}\n"
3829 msgstr ""
3830 "~~~~ {.ignore}\n"
3831 "// main.rs\n"
3832 "extern crate world;\n"
3833 "fn main() { println(~\"hello \" + world::explore()); }\n"
3834 "~~~~"
3835
3836 #. type: Plain text
3837 #: src/doc/tutorial.md:2189
3838 #, fuzzy
3839 #| msgid "# 1.print(); # (~\"foo\").print(); ~~~~"
3840 msgid "# true.print(); # 3.14159.print(); ~~~~"
3841 msgstr ""
3842 "# 1.print();\n"
3843 "# (~\"foo\").print();\n"
3844 "~~~~"
3845
3846 #. type: Plain text
3847 #: src/doc/tutorial.md:2216
3848 #, fuzzy
3849 #| msgid "# 1.print(); # (~\"foo\").print(); ~~~~"
3850 msgid ""
3851 "# 1.print(); # (~\"foo\").print(); # true.print(); # 3.14159.print(); ~~~~"
3852 msgstr ""
3853 "# 1.print();\n"
3854 "# (~\"foo\").print();\n"
3855 "~~~~"
3856
3857 #. type: Plain text
3858 #: src/doc/tutorial.md:2227
3859 #, fuzzy
3860 #| msgid "## Tuples"
3861 msgid "## Type-parameterized traits"
3862 msgstr "## タプル"
3863
3864 #. type: Plain text
3865 #: src/doc/tutorial.md:2235
3866 #, fuzzy, no-wrap
3867 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
3868 msgid ""
3869 "~~~~\n"
3870 "trait Seq<T> {\n"
3871 "    fn length(&self) -> uint;\n"
3872 "}\n"
3873 msgstr ""
3874 "~~~~ {.ignore}\n"
3875 "// main.rs\n"
3876 "extern crate world;\n"
3877 "fn main() { println(~\"hello \" + world::explore()); }\n"
3878 "~~~~"
3879
3880 #. type: Plain text
3881 #: src/doc/tutorial.md:2240
3882 #, fuzzy, no-wrap
3883 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
3884 msgid ""
3885 "impl<T> Seq<T> for ~[T] {\n"
3886 "    fn length(&self) -> uint { self.len() }\n"
3887 "}\n"
3888 "~~~~\n"
3889 msgstr ""
3890 "~~~~ {.ignore}\n"
3891 "// main.rs\n"
3892 "extern crate world;\n"
3893 "fn main() { println(~\"hello \" + world::explore()); }\n"
3894 "~~~~"
3895
3896 #. type: Plain text
3897 #: src/doc/tutorial.md:2247
3898 msgid ""
3899 "The implementation has to explicitly declare the type parameter that it "
3900 "binds, `T`, before using it to specify its trait type. Rust requires this "
3901 "declaration because the `impl` could also, for example, specify an "
3902 "implementation of `Seq<int>`. The trait type (appearing between `impl` and "
3903 "`for`) *refers* to a type, rather than defining one."
3904 msgstr ""
3905 "実装が束縛する型パラメータ `T` は、トレイトの型を指定する前に明示的に宣言しな"
3906 "ければなりません。Rust でこの宣言が必要なのは、 `impl` では例えば `Seq<int>` "
3907 "の実装を指定することも可能だからです。トレイトの型 (`impl` と `for` の間に現"
3908 "れるもの) は、型を定義するのではなく、型を **参照** します。"
3909
3910 #. type: Plain text
3911 #: src/doc/tutorial.md:2252
3912 msgid ""
3913 "The type parameters bound by a trait are in scope in each of the method "
3914 "declarations. So, re-declaring the type parameter `T` as an explicit type "
3915 "parameter for `len`, in either the trait or the impl, would be a compile-"
3916 "time error."
3917 msgstr ""
3918 "トレイトにより束縛される型パラメータは、各メソッドの宣言のスコープに属しま"
3919 "す。したがって、trait と impl のいずれかで、型パラメータ `T` を `len` で用い"
3920 "る明示的な型パラメータとして再宣言すると、コンパイル時エラーとなります。"
3921
3922 #. type: Plain text
3923 #: src/doc/tutorial.md:2257
3924 msgid ""
3925 "Within a trait definition, `Self` is a special type that you can think of as "
3926 "a type parameter. An implementation of the trait for any given type `T` "
3927 "replaces the `Self` type parameter with `T`. The following trait describes "
3928 "types that support an equality operation:"
3929 msgstr ""
3930 "トレイトの定義内部では、`Self` は型パラメータとみなすことのできる特別な型とな"
3931 "ります。型 `T` に対するトレイトの実装では `Self` は型パラメータ `T` で置き換"
3932 "えられます。以下のトレイトは等価性演算をサポートする型を意味します。"
3933
3934 #. type: Plain text
3935 #: src/doc/tutorial.md:2264
3936 #, no-wrap
3937 msgid ""
3938 "~~~~\n"
3939 "// In a trait, `self` refers to the self argument.\n"
3940 "// `Self` refers to the type implementing the trait.\n"
3941 "trait Eq {\n"
3942 "    fn equals(&self, other: &Self) -> bool;\n"
3943 "}\n"
3944 msgstr ""
3945 "~~~~\n"
3946 "// trait の内側では, `self` は self 引数を指します。\n"
3947 "// `Self` はトレイトを実装する型を指します。\n"
3948 "trait Eq {\n"
3949 "    fn equals(&self, other: &Self) -> bool;\n"
3950 "}\n"
3951
3952 #. type: Plain text
3953 #: src/doc/tutorial.md:2270
3954 #, no-wrap
3955 msgid ""
3956 "// In an impl, `self` refers just to the value of the receiver\n"
3957 "impl Eq for int {\n"
3958 "    fn equals(&self, other: &int) -> bool { *other == *self }\n"
3959 "}\n"
3960 "~~~~\n"
3961 msgstr ""
3962 "// impl の内側では `self` はレシーバの値を指します\n"
3963 "impl Eq for int {\n"
3964 "    fn equals(&self, other: &int) -> bool { *other == *self }\n"
3965 "}\n"
3966 "~~~~\n"
3967
3968 #. type: Plain text
3969 #: src/doc/tutorial.md:2275
3970 msgid ""
3971 "Notice that in the trait definition, `equals` takes a second parameter of "
3972 "type `Self`.  In contrast, in the `impl`, `equals` takes a second parameter "
3973 "of type `int`, only using `self` as the name of the receiver."
3974 msgstr ""
3975 "トレイトの定義では、`equals` の第二引数の型は `Self` であることに注意してくだ"
3976 "さい。対照的に `impl` では、 `equals` の第二引数の型は `int` で、 `self` はレ"
3977 "シーバの名前としてのみ使用されます。"
3978
3979 #. type: Plain text
3980 #: src/doc/tutorial.md:2280
3981 msgid ""
3982 "Just as in type implementations, traits can define standalone (static)  "
3983 "methods.  These methods are called by prefixing the method name with the "
3984 "trait name and a double colon.  The compiler uses type inference to decide "
3985 "which implementation to use."
3986 msgstr ""
3987 "型への実装の場合と同様、トレイトもスタンドアロン (静的) メソッドを定義するこ"
3988 "とができます。メソッド名の前にトレイト名とコロン2つをつけることで、これらのメ"
3989 "ソッドを呼び出すことができます。コンパイラはどの実装を利用するか決定するた"
3990 "め、型推論を行います。"
3991
3992 #. type: Plain text
3993 #: src/doc/tutorial.md:2286
3994 #, fuzzy
3995 #| msgid ""
3996 #| "~~~~ use std::f64::consts::pi; trait Shape { fn new(area: f64) -> Self; } "
3997 #| "struct Circle { radius: f64 } struct Square { length: f64 }"
3998 msgid ""
3999 "~~~~ use std::f64::consts::PI; trait Shape { fn new(area: f64) -> Self; } "
4000 "struct Circle { radius: f64 } struct Square { length: f64 }"
4001 msgstr ""
4002 "~~~~\n"
4003 "use std::f64::consts::pi;\n"
4004 "trait Shape { fn new(area: f64) -> Self; }\n"
4005 "struct Circle { radius: f64 }\n"
4006 "struct Square { length: f64 }"
4007
4008 #. type: Plain text
4009 #: src/doc/tutorial.md:2298
4010 msgid ""
4011 "let area = 42.5; let c: Circle = Shape::new(area); let s: Square = Shape::"
4012 "new(area); ~~~~"
4013 msgstr ""
4014 "let area = 42.5;\n"
4015 "let c: Circle = Shape::new(area);\n"
4016 "let s: Square = Shape::new(area);\n"
4017 "~~~~"
4018
4019 #. type: Plain text
4020 #: src/doc/tutorial.md:2300
4021 msgid "## Bounded type parameters and static method dispatch"
4022 msgstr "## 境界型パラメータと静的メソッドディスパッチ"
4023
4024 #. type: Plain text
4025 #: src/doc/tutorial.md:2305
4026 msgid ""
4027 "Traits give us a language for defining predicates on types, or abstract "
4028 "properties that types can have. We can use this language to define _bounds_ "
4029 "on type parameters, so that we can then operate on generic types."
4030 msgstr ""
4031 "トレイトは型の述語 (predicate) や型がもつことのできる抽象的な属性を定義するた"
4032 "めの言語として利用することができます。この言語を使うこととで型パラメータの __"
4033 "境界__ (_bound_) を定義することができ、ジェネリックな型を操作することが可能に"
4034 "なります。"
4035
4036 #. type: Plain text
4037 #: src/doc/tutorial.md:2320
4038 msgid ""
4039 "Declaring `T` as conforming to the `Printable` trait (as we earlier did with "
4040 "`Clone`) makes it possible to call methods from that trait on values of type "
4041 "`T` inside the function. It will also cause a compile-time error when anyone "
4042 "tries to call `print_all` on an array whose element type does not have a "
4043 "`Printable` implementation."
4044 msgstr ""
4045 "(先に登場した `Clone` の例のように) `T` が `Printable` トレイトに従うことを宣"
4046 "言することで、関数内部で `T` 型の値に対して `Printable` トレイトのメソッドを"
4047 "呼び出すことが可能になります。また、この宣言により、`Printable` を実装してい"
4048 "ない型を要素とする配列に対して `print_all` 関数を呼びだそうとすると、コンパイ"
4049 "ル時エラーとなります。"
4050
4051 #. type: Plain text
4052 #: src/doc/tutorial.md:2323
4053 msgid ""
4054 "Type parameters can have multiple bounds by separating them with `+`, as in "
4055 "this version of `print_all` that copies elements."
4056 msgstr ""
4057 "型パラメータは `+` で区切ることで複数の境界を持つことができます。以下の "
4058 "`print_all` は、ベクタの要素をコピーするバージョンです。"
4059
4060 #. type: Plain text
4061 #: src/doc/tutorial.md:2339
4062 msgid ""
4063 "Method calls to bounded type parameters are _statically dispatched_, "
4064 "imposing no more overhead than normal function invocation, so are the "
4065 "preferred way to use traits polymorphically."
4066 msgstr ""
4067 "境界型パラメータに対するメソッドの呼び出しは __静的にディスパッチ__ "
4068 "(_statically dispatched_) されるため、通常の関数呼び出し以上のオーバーヘッド"
4069 "は発生しません。そのため、ポリモーフィックにトレイトを使う方法としては、境界"
4070 "型パラメータが推奨されます。 "
4071
4072 #. type: Plain text
4073 #: src/doc/tutorial.md:2341
4074 msgid "This usage of traits is similar to Haskell type classes."
4075 msgstr "トレイトのこのような使い方は、Haskell の型クラスと似ています。"
4076
4077 #. type: Plain text
4078 #: src/doc/tutorial.md:2343
4079 msgid "## Trait objects and dynamic method dispatch"
4080 msgstr "## トレイトオブジェクトと動的メソッドディスパッチ"
4081
4082 #. type: Plain text
4083 #: src/doc/tutorial.md:2347
4084 msgid ""
4085 "The above allows us to define functions that polymorphically act on values "
4086 "of a single unknown type that conforms to a given trait.  However, consider "
4087 "this function:"
4088 msgstr ""
4089 "上述の例では、指定されたトレイトに従う、単一の未知の型の値についてポリモー"
4090 "フィックにふるまう関数を定義しました。ここでは、以下の関数について考えます。"
4091
4092 #. type: Plain text
4093 #: src/doc/tutorial.md:2353
4094 msgid ""
4095 "~~~~ # type Circle = int; type Rectangle = int; # impl Drawable for int { fn "
4096 "draw(&self) {} } # fn new_circle() -> int { 1 } trait Drawable { fn "
4097 "draw(&self); }"
4098 msgstr ""
4099 "~~~~\n"
4100 "# type Circle = int; type Rectangle = int;\n"
4101 "# impl Drawable for int { fn draw(&self) {} }\n"
4102 "# fn new_circle() -> int { 1 }\n"
4103 "trait Drawable { fn draw(&self); }"
4104
4105 #. type: Plain text
4106 #: src/doc/tutorial.md:2366
4107 msgid ""
4108 "You can call that on an array of circles, or an array of rectangles "
4109 "(assuming those have suitable `Drawable` traits defined), but not on an "
4110 "array containing both circles and rectangles. When such behavior is needed, "
4111 "a trait name can alternately be used as a type, called an _object_."
4112 msgstr ""
4113 "円の配列や長方形の配列に対してこの関数を呼び出すことは (円や長方形に対し適切"
4114 "に `Drawable` トレイトが定義されていると仮定すれば) 可能ですが、円や長方形を"
4115 "両方共含む配列に対しては呼び出すことができません。そのような動作が必要な場"
4116 "合、__オブジェクト__  型として、トレイトの名前を代わりに利用することができま"
4117 "す。"
4118
4119 #. type: Plain text
4120 #: src/doc/tutorial.md:2378
4121 msgid ""
4122 "In this example, there is no type parameter. Instead, the `@Drawable` type "
4123 "denotes any managed box value that implements the `Drawable` trait. To "
4124 "construct such a value, you use the `as` operator to cast a value to an "
4125 "object:"
4126 msgstr ""
4127 "この例中には、型パラメータはありません。代わりに、「`Drawable` トレイトを実装"
4128 "した、任意のマネージドボックス値」を表す型  `@Drawable` 型があります。このよ"
4129 "うな値を作成するには、 `as` 演算子を使って値をオブジェクトへキャストします。"
4130
4131 #. type: Plain text
4132 #: src/doc/tutorial.md:2385
4133 msgid ""
4134 "~~~~ # type Circle = int; type Rectangle = bool; # trait Drawable { fn "
4135 "draw(&self); } # fn new_circle() -> Circle { 1 } # fn new_rectangle() -> "
4136 "Rectangle { true } # fn draw_all(shapes: &[@Drawable]) {}"
4137 msgstr ""
4138 "~~~~\n"
4139 "# type Circle = int; type Rectangle = bool;\n"
4140 "# trait Drawable { fn draw(&self); }\n"
4141 "# fn new_circle() -> Circle { 1 }\n"
4142 "# fn new_rectangle() -> Rectangle { true }\n"
4143 "# fn draw_all(shapes: &[@Drawable]) {}"
4144
4145 #. type: Plain text
4146 #: src/doc/tutorial.md:2388
4147 msgid ""
4148 "impl Drawable for Circle { fn draw(&self) { ... } } impl Drawable for "
4149 "Rectangle { fn draw(&self) { ... } }"
4150 msgstr ""
4151 "impl Drawable for Circle { fn draw(&self) { ... } }\n"
4152 "impl Drawable for Rectangle { fn draw(&self) { ... } }"
4153
4154 #. type: Plain text
4155 #: src/doc/tutorial.md:2393
4156 msgid ""
4157 "let c: @Circle = @new_circle(); let r: @Rectangle = @new_rectangle(); "
4158 "draw_all([c as @Drawable, r as @Drawable]); ~~~~"
4159 msgstr ""
4160 "let c: @Circle = @new_circle();\n"
4161 "let r: @Rectangle = @new_rectangle();\n"
4162 "draw_all([c as @Drawable, r as @Drawable]);\n"
4163 "~~~~"
4164
4165 #. type: Plain text
4166 #: src/doc/tutorial.md:2401
4167 msgid ""
4168 "We omit the code for `new_circle` and `new_rectangle`; imagine that these "
4169 "just return `Circle`s and `Rectangle`s with a default size. Note that, like "
4170 "strings and vectors, objects have dynamic size and may only be referred to "
4171 "via one of the pointer types.  Other pointer types work as well.  Casts to "
4172 "traits may only be done with compatible pointers so, for example, an "
4173 "`@Circle` may not be cast to an `~Drawable`."
4174 msgstr ""
4175 "`new_circle` と `new_rectangle` のコードは省略されていますが、デフォルトのサ"
4176 "イズをもつ `Circle` と `Rectangle` をただ返すものだと考えてください。文字列や"
4177 "ベクタのように、オブジェクトも動的なサイズを持ち、いずれかのポインタ型を経由"
4178 "してしか参照できないことに注意してください。他のポインタ型でもうまく動作しま"
4179 "す。トレイトへのキャストは互換性のあるポインタの場合しか行えません。例えば、"
4180 "`@Cicle` を `~Drawable` にキャストすることはできません。"
4181
4182 #. type: Plain text
4183 #: src/doc/tutorial.md:2415
4184 msgid ""
4185 "~~~ # type Circle = int; type Rectangle = int; # trait Drawable { fn "
4186 "draw(&self); } # impl Drawable for int { fn draw(&self) {} } # fn "
4187 "new_circle() -> int { 1 } # fn new_rectangle() -> int { 2 } // A managed "
4188 "object let boxy: @Drawable = @new_circle() as @Drawable; // An owned object "
4189 "let owny: ~Drawable = ~new_circle() as ~Drawable; // A borrowed object let "
4190 "stacky: &Drawable = &new_circle() as &Drawable; ~~~"
4191 msgstr ""
4192 "~~~\n"
4193 "# type Circle = int; type Rectangle = int;\n"
4194 "# trait Drawable { fn draw(&self); }\n"
4195 "# impl Drawable for int { fn draw(&self) {} }\n"
4196 "# fn new_circle() -> int { 1 }\n"
4197 "# fn new_rectangle() -> int { 2 }\n"
4198 "// A managed object\n"
4199 "let boxy: @Drawable = @new_circle() as @Drawable;\n"
4200 "// An owned object\n"
4201 "let owny: ~Drawable = ~new_circle() as ~Drawable;\n"
4202 "// A borrowed object\n"
4203 "let stacky: &Drawable = &new_circle() as &Drawable;\n"
4204 "~~~"
4205
4206 #. type: Plain text
4207 #: src/doc/tutorial.md:2420
4208 msgid ""
4209 "Method calls to trait types are _dynamically dispatched_. Since the compiler "
4210 "doesn't know specifically which functions to call at compile time, it uses a "
4211 "lookup table (also known as a vtable or dictionary) to select the method to "
4212 "call at runtime."
4213 msgstr ""
4214 "トレイト型のメソッド呼び出しは __動的にディスパッチ__ (_dynamically "
4215 "dispatched_) されます。どの関数を呼び出すべきかコンパイル時にはわからないた"
4216 "め、ルックアップテーブル (vtable や dictionary としても知られている) を用い"
4217 "て、呼び出すメソッドの選択を実行時に行います。"
4218
4219 #. type: Plain text
4220 #: src/doc/tutorial.md:2422
4221 msgid "This usage of traits is similar to Java interfaces."
4222 msgstr "トレイトのこのような使い方は、Java のインターフェースと似ています。"
4223
4224 #. type: Plain text
4225 #: src/doc/tutorial.md:2448
4226 msgid "## Trait inheritance"
4227 msgstr "## トレイトの継承"
4228
4229 #. type: Plain text
4230 #: src/doc/tutorial.md:2453
4231 msgid ""
4232 "We can write a trait declaration that _inherits_ from other traits, called "
4233 "_supertraits_.  Types that implement a trait must also implement its "
4234 "supertraits.  For example, we can define a `Circle` trait that inherits from "
4235 "`Shape`."
4236 msgstr ""
4237 "__スーパートレイト__ と呼ばれる他のトレイトから __継承した__ トレイトを宣言す"
4238 "ることができます。継承されたトレイトを実装する型は、スーパートレイトも実装し"
4239 "なければなりません。例えば、 `Circle` トレイトを `Shape` トレイトを継承したも"
4240 "のとして定義できます。"
4241
4242 #. type: Plain text
4243 #: src/doc/tutorial.md:2458
4244 msgid ""
4245 "~~~~ trait Shape { fn area(&self) -> f64; } trait Circle : Shape { fn "
4246 "radius(&self) -> f64; } ~~~~"
4247 msgstr ""
4248 "~~~~\n"
4249 "trait Shape { fn area(&self) -> f64; }\n"
4250 "trait Circle : Shape { fn radius(&self) -> f64; }\n"
4251 "~~~~"
4252
4253 #. type: Plain text
4254 #: src/doc/tutorial.md:2460
4255 msgid ""
4256 "Now, we can implement `Circle` on a type only if we also implement `Shape`."
4257 msgstr "`Circle` トレイトの実装は、 `Shape` を実装した型についてのみ行えます。"
4258
4259 #. type: Plain text
4260 #: src/doc/tutorial.md:2475
4261 #, fuzzy, no-wrap
4262 #| msgid "~~~ {.ignore} use std::f64::consts::pi; # trait Shape { fn area(&self) -> f64; } # trait Circle : Shape { fn radius(&self) -> f64; } # struct Point { x: f64, y: f64 } # struct CircleStruct { center: Point, radius: f64 } # impl Circle for CircleStruct { fn radius(&self) -> f64 { (self.area() / pi).sqrt() } } # impl Shape for CircleStruct { fn area(&self) -> f64 { pi * square(self.radius) } }"
4263 msgid ""
4264 "~~~~\n"
4265 "use std::f64::consts::PI;\n"
4266 "# trait Shape { fn area(&self) -> f64; }\n"
4267 "# trait Circle : Shape { fn radius(&self) -> f64; }\n"
4268 "# struct Point { x: f64, y: f64 }\n"
4269 "# fn square(x: f64) -> f64 { x * x }\n"
4270 "struct CircleStruct { center: Point, radius: f64 }\n"
4271 "impl Circle for CircleStruct {\n"
4272 "    fn radius(&self) -> f64 { (self.area() / PI).sqrt() }\n"
4273 "}\n"
4274 "impl Shape for CircleStruct {\n"
4275 "    fn area(&self) -> f64 { PI * square(self.radius) }\n"
4276 "}\n"
4277 "~~~~\n"
4278 msgstr ""
4279 "~~~ {.ignore}\n"
4280 "use std::f64::consts::pi;\n"
4281 "# trait Shape { fn area(&self) -> f64; }\n"
4282 "# trait Circle : Shape { fn radius(&self) -> f64; }\n"
4283 "# struct Point { x: f64, y: f64 }\n"
4284 "# struct CircleStruct { center: Point, radius: f64 }\n"
4285 "# impl Circle for CircleStruct { fn radius(&self) -> f64 { (self.area() / pi).sqrt() } }\n"
4286 "# impl Shape for CircleStruct { fn area(&self) -> f64 { pi * square(self.radius) } }"
4287
4288 #. type: Plain text
4289 #: src/doc/tutorial.md:2480
4290 msgid ""
4291 "Notice that methods of `Circle` can call methods on `Shape`, as our `radius` "
4292 "implementation calls the `area` method.  This is a silly way to compute the "
4293 "radius of a circle (since we could just return the `radius` field), but you "
4294 "get the idea."
4295 msgstr ""
4296 "`radius` の実装から `area` メソッドを呼び出せるように、`Circle` のメソッドは "
4297 "`Shape` のメソッドを呼び出せることに注意してください。(単純に `radius` フィー"
4298 "ルドの値を返すことができるにも関わらず) 円の半径を面積から計算するのは馬鹿げ"
4299 "ていますが、メソッド呼び出しの考え方は分かったでしょう。"
4300
4301 #. type: Plain text
4302 #: src/doc/tutorial.md:2484
4303 msgid ""
4304 "In type-parameterized functions, methods of the supertrait may be called on "
4305 "values of subtrait-bound type parameters.  Refering to the previous example "
4306 "of `trait Circle : Shape`:"
4307 msgstr ""
4308 "型パラメータを持つ関数では、サブトレイトの境界型パラメータの値によりスーパー"
4309 "トレイトのメソッドを呼び出すことになります。前の例の `trait Circle : Shape` "
4310 "を参照してください。"
4311
4312 #. type: Plain text
4313 #: src/doc/tutorial.md:2493
4314 #, no-wrap
4315 msgid ""
4316 "~~~\n"
4317 "# trait Shape { fn area(&self) -> f64; }\n"
4318 "# trait Circle : Shape { fn radius(&self) -> f64; }\n"
4319 "fn radius_times_area<T: Circle>(c: T) -> f64 {\n"
4320 "    // `c` is both a Circle and a Shape\n"
4321 "    c.radius() * c.area()\n"
4322 "}\n"
4323 "~~~\n"
4324 msgstr ""
4325 "~~~\n"
4326 "# trait Shape { fn area(&self) -> f64; }\n"
4327 "# trait Circle : Shape { fn radius(&self) -> f64; }\n"
4328 "fn radius_times_area<T: Circle>(c: T) -> f64 {\n"
4329 "    // `c` は Circle でもあり、Shape でもある\n"
4330 "    c.radius() * c.area()\n"
4331 "}\n"
4332 "~~~\n"
4333
4334 #. type: Plain text
4335 #: src/doc/tutorial.md:2504
4336 #, fuzzy
4337 #| msgid ""
4338 #| "~~~ {.ignore} use std::f64::consts::pi; # trait Shape { fn area(&self) -> "
4339 #| "f64; } # trait Circle : Shape { fn radius(&self) -> f64; } # struct Point "
4340 #| "{ x: f64, y: f64 } # struct CircleStruct { center: Point, radius: f64 } # "
4341 #| "impl Circle for CircleStruct { fn radius(&self) -> f64 { (self.area() / "
4342 #| "pi).sqrt() } } # impl Shape for CircleStruct { fn area(&self) -> f64 { pi "
4343 #| "* square(self.radius) } }"
4344 msgid ""
4345 "~~~ {.ignore} use std::f64::consts::PI; # trait Shape { fn area(&self) -> "
4346 "f64; } # trait Circle : Shape { fn radius(&self) -> f64; } # struct Point "
4347 "{ x: f64, y: f64 } # struct CircleStruct { center: Point, radius: f64 } # "
4348 "impl Circle for CircleStruct { fn radius(&self) -> f64 { (self.area() / PI)."
4349 "sqrt() } } # impl Shape for CircleStruct { fn area(&self) -> f64 { PI * "
4350 "square(self.radius) } }"
4351 msgstr ""
4352 "~~~ {.ignore}\n"
4353 "use std::f64::consts::pi;\n"
4354 "# trait Shape { fn area(&self) -> f64; }\n"
4355 "# trait Circle : Shape { fn radius(&self) -> f64; }\n"
4356 "# struct Point { x: f64, y: f64 }\n"
4357 "# struct CircleStruct { center: Point, radius: f64 }\n"
4358 "# impl Circle for CircleStruct { fn radius(&self) -> f64 { (self.area() / "
4359 "pi).sqrt() } }\n"
4360 "# impl Shape for CircleStruct { fn area(&self) -> f64 { pi * square(self."
4361 "radius) } }"
4362
4363 #. type: Plain text
4364 #: src/doc/tutorial.md:2509
4365 msgid ""
4366 "let concrete = @CircleStruct{center:Point{x:3f,y:4f},radius:5f}; let "
4367 "mycircle: @Circle = concrete as @Circle; let nonsense = mycircle.radius() * "
4368 "mycircle.area(); ~~~"
4369 msgstr ""
4370 "let concrete = @CircleStruct{center:Point{x:3f,y:4f},radius:5f};\n"
4371 "let mycircle: @Circle = concrete as @Circle;\n"
4372 "let nonsense = mycircle.radius() * mycircle.area();\n"
4373 "~~~"
4374
4375 #. type: Plain text
4376 #: src/doc/tutorial.md:2511
4377 msgid "> *Note:* Trait inheritance does not actually work with objects yet"
4378 msgstr ""
4379 "> *注意* トレイトの継承は、実際にはまだオブジェクトに対しては動作しませ"
4380 "ん。"
4381
4382 #. type: Plain text
4383 #: src/doc/tutorial.md:2513
4384 msgid "## Deriving implementations for traits"
4385 msgstr "## トレイトの実装の導出"
4386
4387 #. type: Plain text
4388 #: src/doc/tutorial.md:2520
4389 msgid ""
4390 "A small number of traits in `std` and `extra` can have implementations that "
4391 "can be automatically derived. These instances are specified by placing the "
4392 "`deriving` attribute on a data type declaration. For example, the following "
4393 "will mean that `Circle` has an implementation for `Eq` and can be used with "
4394 "the equality operators, and that a value of type `ABC` can be randomly "
4395 "generated and converted to a string:"
4396 msgstr ""
4397 "`std` と `extra` で定義されているいくつかのトレイトは、自動的に実装を導出可能"
4398 "です。データ型の宣言時に `deriving` 属性を書くことで、これらのトレイトを実装"
4399 "することを指定します。例えば、以下の例では `Circle` は `Eq` を実装し等価演算"
4400 "子で比較することが可能であり、`ABC` 型の値はランダムに生成することや、文字列"
4401 "に変換することが可能です。"
4402
4403 #. type: Plain text
4404 #: src/doc/tutorial.md:2524
4405 msgid "~~~ #[deriving(Eq)] struct Circle { radius: f64 }"
4406 msgstr ""
4407 "~~~\n"
4408 "#[deriving(Eq)]\n"
4409 "struct Circle { radius: f64 }"
4410
4411 #. type: Plain text
4412 #: src/doc/tutorial.md:2528
4413 msgid "#[deriving(Rand, ToStr)] enum ABC { A, B, C } ~~~"
4414 msgstr ""
4415 "#[deriving(Rand, ToStr)]\n"
4416 "enum ABC { A, B, C }\n"
4417 "~~~"
4418
4419 #. type: Plain text
4420 #: src/doc/tutorial.md:2532
4421 #, fuzzy
4422 #| msgid ""
4423 #| "The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
4424 #| "`Encodable` `Decodable`, `Clone`, `DeepClone`, `Hash`, `Rand`, "
4425 #| "`Zero`, and `ToStr`."
4426 msgid ""
4427 "The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
4428 "`Encodable` `Decodable`, `Clone`, `DeepClone`, `Hash`, `Rand`, "
4429 "`Default`, `Zero`, and `ToStr`."
4430 msgstr ""
4431 "実装を自動的に導出可能なトレイトは、 `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
4432 "`Encodable` `Decodable`, `Clone`, `DeepClone`, `Hash`, `Rand`, `Zero`, "
4433 "および `ToStr` です。."
4434
4435 #. type: Plain text
4436 #: src/doc/tutorial.md:2534
4437 #, fuzzy
4438 #| msgid "# Modules and crates"
4439 msgid "# Crates and the module system"
4440 msgstr "# モジュールとクレート"
4441
4442 #. type: Plain text
4443 #: src/doc/tutorial.md:2539
4444 msgid "## Crates"
4445 msgstr "## クレート"
4446
4447 #. type: Plain text
4448 #: src/doc/tutorial.md:2554
4449 #, fuzzy, no-wrap
4450 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
4451 msgid ""
4452 "~~~~\n"
4453 "// `main.rs`\n"
4454 "fn main() {\n"
4455 "    println!(\"Hello world!\");\n"
4456 "}\n"
4457 "~~~~\n"
4458 msgstr ""
4459 "~~~~ {.ignore}\n"
4460 "// main.rs\n"
4461 "extern crate world;\n"
4462 "fn main() { println(~\"hello \" + world::explore()); }\n"
4463 "~~~~"
4464
4465 #. type: Plain text
4466 #: src/doc/tutorial.md:2557
4467 #, fuzzy
4468 #| msgid ""
4469 #| "The unit of independent compilation in Rust is the crate: rustc compiles "
4470 #| "a single crate at a time, from which it produces either a library or an "
4471 #| "executable."
4472 msgid ""
4473 "A crate is also the unit of independent compilation in Rust: `rustc` always "
4474 "compiles a single crate at a time, from which it produces either a library "
4475 "or an executable."
4476 msgstr ""
4477 "Rust の独立コンパイルの単位はクレートです。rustc は1度に1つのクレートをコンパ"
4478 "イルし、ライブラリか実行可能ファイルを生成します。"
4479
4480 #. type: Plain text
4481 #: src/doc/tutorial.md:2561
4482 #, fuzzy
4483 #| msgid "## The standard library"
4484 msgid "## The module hierarchy"
4485 msgstr "## 標準ライブラリ"
4486
4487 #. type: Plain text
4488 #: src/doc/tutorial.md:2587
4489 #, fuzzy, no-wrap
4490 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
4491 msgid ""
4492 "fn main() {\n"
4493 "    println!(\"Hello farm!\");\n"
4494 "}\n"
4495 "~~~~\n"
4496 msgstr ""
4497 "~~~~ {.ignore}\n"
4498 "// main.rs\n"
4499 "extern crate world;\n"
4500 "fn main() { println(~\"hello \" + world::explore()); }\n"
4501 "~~~~"
4502
4503 #. type: Plain text
4504 #: src/doc/tutorial.md:2595
4505 #, fuzzy
4506 #| msgid "## Managed closures"
4507 msgid "## Paths and visibility"
4508 msgstr "## マネージドクロージャ"
4509
4510 #. type: Plain text
4511 #: src/doc/tutorial.md:2607
4512 #, fuzzy, no-wrap
4513 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
4514 msgid ""
4515 "fn main() {\n"
4516 "    println!(\"Hello chicken!\");\n"
4517 msgstr ""
4518 "~~~~ {.ignore}\n"
4519 "// main.rs\n"
4520 "extern crate world;\n"
4521 "fn main() { println(~\"hello \" + world::explore()); }\n"
4522 "~~~~"
4523
4524 #. type: Plain text
4525 #: src/doc/tutorial.md:2639
4526 #, fuzzy, no-wrap
4527 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
4528 msgid ""
4529 "fn main() {\n"
4530 "    println!(\"Hello chicken!\");\n"
4531 "    ::farm::chicken(); // This compiles now\n"
4532 "}\n"
4533 "~~~~\n"
4534 msgstr ""
4535 "~~~~ {.ignore}\n"
4536 "// main.rs\n"
4537 "extern crate world;\n"
4538 "fn main() { println(~\"hello \" + world::explore()); }\n"
4539 "~~~~"
4540
4541 #. type: Plain text
4542 #: src/doc/tutorial.md:2646
4543 #, fuzzy
4544 #| msgid ""
4545 #| "Visibility restrictions in Rust exist only at module boundaries. This is "
4546 #| "quite different from most object-oriented languages that also enforce "
4547 #| "restrictions on objects themselves. That's not to say that Rust doesn't "
4548 #| "support encapsulation: both struct fields and methods can be private. But "
4549 #| "this encapsulation is at the module level, not the struct level. Note "
4550 #| "that fields and methods are _public_ by default."
4551 msgid ""
4552 "Visibility restrictions in Rust exist only at module boundaries. This is "
4553 "quite different from most object-oriented languages that also enforce "
4554 "restrictions on objects themselves. That's not to say that Rust doesn't "
4555 "support encapsulation: both struct fields and methods can be private. But "
4556 "this encapsulation is at the module level, not the struct level."
4557 msgstr ""
4558 "Rust での可視性の制約はモジュールの境界にのみ存在します。これは、オブジェクト"
4559 "自体にも可視性の制約を課すほとんどのオブジェクト指向言語とは全く異なっていま"
4560 "す。しかし、Rust がカプセル化をサポートしていないというわけではありません。構"
4561 "造体のフィールドとメソッドはプライベートにすることができます。しかし、このカ"
4562 "プセル化はモジュールレベルで働くもので、構造体のレベルで働くものではありませ"
4563 "ん。フィールドとメソッドでは、デフォルトでは __パブリック__ であることに注意"
4564 "してください。"
4565
4566 #. type: Plain text
4567 #: src/doc/tutorial.md:2689
4568 #, fuzzy
4569 #| msgid "# Modules and crates"
4570 msgid "## Files and modules"
4571 msgstr "# モジュールとクレート"
4572
4573 #. type: Plain text
4574 #: src/doc/tutorial.md:2719
4575 #, fuzzy, no-wrap
4576 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
4577 msgid ""
4578 "fn main() {\n"
4579 "    println!(\"Hello farm!\");\n"
4580 "    ::farm::cow();\n"
4581 "}\n"
4582 "~~~~\n"
4583 msgstr ""
4584 "~~~~ {.ignore}\n"
4585 "// main.rs\n"
4586 "extern crate world;\n"
4587 "fn main() { println(~\"hello \" + world::explore()); }\n"
4588 "~~~~"
4589
4590 #. type: Plain text
4591 #: src/doc/tutorial.md:2755
4592 #, fuzzy, no-wrap
4593 #| msgid "~~~~ {.ignore} let foo = 10;"
4594 msgid ""
4595 "~~~ {.ignore}\n"
4596 "// `src/main.rs`\n"
4597 "mod plants;\n"
4598 "mod animals {\n"
4599 "    mod fish;\n"
4600 "    mod mammals {\n"
4601 "        mod humans;\n"
4602 "    }\n"
4603 "}\n"
4604 "~~~\n"
4605 msgstr ""
4606 "~~~~ {.ignore}\n"
4607 "let foo = 10;"
4608
4609 #. type: Plain text
4610 #: src/doc/tutorial.md:2761 src/doc/tutorial.md:2793
4611 #, fuzzy
4612 #| msgid "~~~~ {.ignore} let foo = 10;"
4613 msgid "~~~ {.notrust} src/plants.rs src/plants/mod.rs"
4614 msgstr ""
4615 "~~~~ {.ignore}\n"
4616 "let foo = 10;"
4617
4618 #. type: Plain text
4619 #: src/doc/tutorial.md:2778
4620 #, fuzzy
4621 #| msgid "~~~~ {.ignore} let foo = 10;"
4622 msgid "~~~ {.ignore} // `src/main.rs` mod plants; mod animals; ~~~"
4623 msgstr ""
4624 "~~~~ {.ignore}\n"
4625 "let foo = 10;"
4626
4627 #. type: Plain text
4628 #: src/doc/tutorial.md:2786
4629 #, fuzzy, no-wrap
4630 #| msgid "~~~~ {.ignore} let foo = 10;"
4631 msgid ""
4632 "~~~ {.ignore}\n"
4633 "// `src/animals.rs` or `src/animals/mod.rs`\n"
4634 "mod fish;\n"
4635 "mod mammals {\n"
4636 "    mod humans;\n"
4637 "}\n"
4638 "~~~\n"
4639 msgstr ""
4640 "~~~~ {.ignore}\n"
4641 "let foo = 10;"
4642
4643 #. type: Plain text
4644 #: src/doc/tutorial.md:2820
4645 #, fuzzy
4646 #| msgid "~~~~ {.ignore} let foo = 10;"
4647 msgid "~~~ {.ignore} #[path=\"../../area51/alien.rs\"] mod classified; ~~~"
4648 msgstr ""
4649 "~~~~ {.ignore}\n"
4650 "let foo = 10;"
4651
4652 #. type: Plain text
4653 #: src/doc/tutorial.md:2897
4654 #, fuzzy
4655 #| msgid ""
4656 #| "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello "
4657 #| "\" + world::explore()); } ~~~~"
4658 msgid "fn main() { cow() } ~~~"
4659 msgstr ""
4660 "~~~~ {.ignore}\n"
4661 "// main.rs\n"
4662 "extern crate world;\n"
4663 "fn main() { println(~\"hello \" + world::explore()); }\n"
4664 "~~~~"
4665
4666 #. type: Plain text
4667 #: src/doc/tutorial.md:2916
4668 #, fuzzy, no-wrap
4669 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
4670 msgid ""
4671 "fn main() {\n"
4672 "    println!(\"Hello farm!\");\n"
4673 msgstr ""
4674 "~~~~ {.ignore}\n"
4675 "// main.rs\n"
4676 "extern crate world;\n"
4677 "fn main() { println(~\"hello \" + world::explore()); }\n"
4678 "~~~~"
4679
4680 #. type: Plain text
4681 #: src/doc/tutorial.md:2923
4682 #, fuzzy, no-wrap
4683 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
4684 msgid ""
4685 "    // Can now refer to those names directly:\n"
4686 "    chicken();\n"
4687 "    cow();\n"
4688 "    barn::hay();\n"
4689 "}\n"
4690 "~~~~\n"
4691 msgstr ""
4692 "~~~~ {.ignore}\n"
4693 "// main.rs\n"
4694 "extern crate world;\n"
4695 "fn main() { println(~\"hello \" + world::explore()); }\n"
4696 "~~~~"
4697
4698 #. type: Plain text
4699 #: src/doc/tutorial.md:2932
4700 #, fuzzy
4701 #| msgid ""
4702 #| "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello "
4703 #| "\" + world::explore()); } ~~~~"
4704 msgid ""
4705 "~~~{.ignore} // `a.rs` - crate root use b::foo; mod b; fn main() { foo(); } "
4706 "~~~"
4707 msgstr ""
4708 "~~~~ {.ignore}\n"
4709 "// main.rs\n"
4710 "extern crate world;\n"
4711 "fn main() { println(~\"hello \" + world::explore()); }\n"
4712 "~~~~"
4713
4714 #. type: Plain text
4715 #: src/doc/tutorial.md:2939
4716 #, fuzzy
4717 #| msgid ""
4718 #| "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello "
4719 #| "\" + world::explore()); } ~~~~"
4720 msgid ""
4721 "~~~{.ignore} // `b.rs` use b::c::bar; pub mod c; pub fn foo() { bar(); } ~~~"
4722 msgstr ""
4723 "~~~~ {.ignore}\n"
4724 "// main.rs\n"
4725 "extern crate world;\n"
4726 "fn main() { println(~\"hello \" + world::explore()); }\n"
4727 "~~~~"
4728
4729 #. type: Plain text
4730 #: src/doc/tutorial.md:2985
4731 #, fuzzy, no-wrap
4732 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
4733 msgid ""
4734 "fn main() {\n"
4735 "    egg_layer();\n"
4736 "}\n"
4737 "~~~\n"
4738 msgstr ""
4739 "~~~~ {.ignore}\n"
4740 "// main.rs\n"
4741 "extern crate world;\n"
4742 "fn main() { println(~\"hello \" + world::explore()); }\n"
4743 "~~~~"
4744
4745 #. type: Plain text
4746 #: src/doc/tutorial.md:2991
4747 #, fuzzy
4748 #| msgid "# Dereferencing pointers"
4749 msgid "## Reexporting names"
4750 msgstr "# ポインタのデリファレンス"
4751
4752 #. type: Plain text
4753 #: src/doc/tutorial.md:3014
4754 #, fuzzy, no-wrap
4755 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
4756 msgid ""
4757 "fn main() {\n"
4758 "    farm::chicken();\n"
4759 "    farm::cow();\n"
4760 "    farm::hay();\n"
4761 "}\n"
4762 "~~~\n"
4763 msgstr ""
4764 "~~~~ {.ignore}\n"
4765 "// main.rs\n"
4766 "extern crate world;\n"
4767 "fn main() { println(~\"hello \" + world::explore()); }\n"
4768 "~~~~"
4769
4770 #. type: Plain text
4771 #: src/doc/tutorial.md:3026
4772 #, fuzzy
4773 #| msgid "## Using other crates"
4774 msgid "## Using libraries"
4775 msgstr "## 他のクレートの利用"
4776
4777 #. type: Plain text
4778 #: src/doc/tutorial.md:3035
4779 #, fuzzy
4780 #| msgid "## Using other crates"
4781 msgid "For that, Rust offers you the `extern crate` declaration:"
4782 msgstr "## 他のクレートの利用"
4783
4784 #. type: Plain text
4785 #: src/doc/tutorial.md:3045
4786 #, fuzzy, no-wrap
4787 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
4788 msgid ""
4789 "fn main() {\n"
4790 "    // The rational number '1/2':\n"
4791 "    let one_half = ::extra::rational::Ratio::new(1, 2);\n"
4792 "}\n"
4793 "~~~\n"
4794 msgstr ""
4795 "~~~~ {.ignore}\n"
4796 "// main.rs\n"
4797 "extern crate world;\n"
4798 "fn main() { println(~\"hello \" + world::explore()); }\n"
4799 "~~~~"
4800
4801 #. type: Plain text
4802 #: src/doc/tutorial.md:3068
4803 #, fuzzy
4804 #| msgid "~~~~ {.ignore} let foo = 10;"
4805 msgid "~~~ extern crate extra;"
4806 msgstr ""
4807 "~~~~ {.ignore}\n"
4808 "let foo = 10;"
4809
4810 #. type: Plain text
4811 #: src/doc/tutorial.md:3081
4812 #, fuzzy, no-wrap
4813 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
4814 msgid ""
4815 "fn main() {\n"
4816 "    farm::dog();\n"
4817 "    let a_third = Ratio::new(1, 3);\n"
4818 "}\n"
4819 "~~~\n"
4820 msgstr ""
4821 "~~~~ {.ignore}\n"
4822 "// main.rs\n"
4823 "extern crate world;\n"
4824 "fn main() { println(~\"hello \" + world::explore()); }\n"
4825 "~~~~"
4826
4827 #. type: Plain text
4828 #: src/doc/tutorial.md:3086
4829 #, fuzzy
4830 #| msgid "## Structs"
4831 msgid "## Package ids"
4832 msgstr "## 構造体"
4833
4834 #. type: Plain text
4835 #: src/doc/tutorial.md:3123
4836 #, fuzzy
4837 #| msgid ""
4838 #| "~~~~ {.ignore} extern crate farm; extern crate my_farm (name = \"farm\", vers "
4839 #| "= \"2.5\"); extern crate my_auxiliary_farm (name = \"farm\", author = \"mjh"
4840 #| "\"); ~~~~"
4841 msgid ""
4842 "~~~~ {.ignore} extern crate farm; extern crate farm = \"farm#2.5\"; extern crate "
4843 "my_farm = \"farm\"; ~~~~"
4844 msgstr ""
4845 "~~~~ {.ignore}\n"
4846 "extern crate farm;\n"
4847 "extern crate my_farm (name = \"farm\", vers = \"2.5\");\n"
4848 "extern crate my_auxiliary_farm (name = \"farm\", author = \"mjh\");\n"
4849 "~~~~"
4850
4851 #. type: Plain text
4852 #: src/doc/tutorial.md:3134
4853 #, fuzzy
4854 #| msgid "// Make a library (\"bin\" is the default)  #![crate_type = \"lib\"]"
4855 msgid ""
4856 "// This crate is a library (\"bin\" is the default)  #[crate_id = "
4857 "\"farm#2.5\"]; #![crate_type = \"lib\"]"
4858 msgstr ""
4859 "// ライブラリを作成する (\"bin\" がデフォルト値)\n"
4860 "#![crate_type = \"lib\"]"
4861
4862 #. type: Plain text
4863 #: src/doc/tutorial.md:3139
4864 #, fuzzy
4865 #| msgid "// Turn on a warning #[warn(non_camel_case_types)]"
4866 msgid "// Turn on a warning #[warn(non_camel_case_types)] # fn farm() {} ~~~~"
4867 msgstr ""
4868 "// 警告を有効にする\n"
4869 "#[warn(non_camel_case_types)]"
4870
4871 #. type: Plain text
4872 #: src/doc/tutorial.md:3141
4873 msgid "## A minimal example"
4874 msgstr "## 最小限の例"
4875
4876 #. type: Plain text
4877 #: src/doc/tutorial.md:3143
4878 #, fuzzy
4879 #| msgid ""
4880 #| "Now for something that you can actually compile yourself, we have these "
4881 #| "two files:"
4882 msgid "Now for something that you can actually compile yourself."
4883 msgstr ""
4884 "あなた自身で実際にコンパイルが行える例として、以下の2つのファイルを例示しま"
4885 "す。"
4886
4887 #. type: Plain text
4888 #: src/doc/tutorial.md:3153
4889 #, fuzzy
4890 #| msgid ""
4891 #| "~~~~ // world.rs #![link(name = \"world\", vers = \"1.0\")] pub fn "
4892 #| "explore() -> &str { \"world\" } ~~~~"
4893 msgid ""
4894 "~~~~ // `world.rs` #![crate_id = \"world#0.42\"] # extern crate extra; pub fn "
4895 "explore() -> &'static str { \"world\" } # fn main() {} ~~~~"
4896 msgstr ""
4897 "~~~~\n"
4898 "// world.rs\n"
4899 "#![link(name = \"world\", vers = \"1.0\")]\n"
4900 "pub fn explore() -> &str { \"world\" }\n"
4901 "~~~~"
4902
4903 #. type: Plain text
4904 #: src/doc/tutorial.md:3159
4905 #, fuzzy
4906 #| msgid ""
4907 #| "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello "
4908 #| "\" + world::explore()); } ~~~~"
4909 msgid ""
4910 "~~~~ {.ignore} // `main.rs` extern crate world; fn main() { println!(\"hello "
4911 "{}\", world::explore()); } ~~~~"
4912 msgstr ""
4913 "~~~~ {.ignore}\n"
4914 "// main.rs\n"
4915 "extern crate world;\n"
4916 "fn main() { println(~\"hello \" + world::explore()); }\n"
4917 "~~~~"
4918
4919 #. type: Plain text
4920 #: src/doc/tutorial.md:3161
4921 msgid "Now compile and run like this (adjust to your platform if necessary):"
4922 msgstr ""
4923 "以下のようにコンパイルし、実行します (必要であれば、お使いのプラットフォーム"
4924 "に合わせて修正してください。)"
4925
4926 #. type: Plain text
4927 #: src/doc/tutorial.md:3168
4928 #, fuzzy, no-wrap
4929 #| msgid ""
4930 #| "~~~~ {.notrust}\n"
4931 #| "> rustc --lib world.rs  # compiles libworld-94839cbfe144198-1.0.so\n"
4932 #| "> rustc main.rs -L .    # compiles main\n"
4933 #| "> ./main\n"
4934 #| "\"hello world\"\n"
4935 #| "~~~~\n"
4936 msgid ""
4937 "~~~~ {.notrust}\n"
4938 "> rustc --lib world.rs  # compiles libworld-<HASH>-0.42.so\n"
4939 "> rustc main.rs -L .    # compiles main\n"
4940 "> ./main\n"
4941 "\"hello world\"\n"
4942 "~~~~\n"
4943 msgstr ""
4944 "~~~~ {.notrust}\n"
4945 "> rustc --lib world.rs  # libworld-94839cbfe144198-1.0.so が生成される\n"
4946 "> rustc main.rs -L .    # main が生成される\n"
4947 "> ./main\n"
4948 "\"hello world\"\n"
4949 "~~~~\n"
4950
4951 #. type: Plain text
4952 #: src/doc/tutorial.md:3173
4953 #, fuzzy
4954 #| msgid ""
4955 #| "Notice that the library produced contains the version in the filename as "
4956 #| "well as an inscrutable string of alphanumerics. These are both part of "
4957 #| "Rust's library versioning scheme. The alphanumerics are a hash "
4958 #| "representing the crate metadata."
4959 msgid ""
4960 "Notice that the library produced contains the version in the file name as "
4961 "well as an inscrutable string of alphanumerics. As explained in the previous "
4962 "paragraph, these are both part of Rust's library versioning scheme. The "
4963 "alphanumerics are a hash representing the crates package ID."
4964 msgstr ""
4965 "生成されたライブラリのファイル名には、バージョン番号だけでなく謎めいた英数字"
4966 "が含まれていることに注意してください。これらは両方共 Rust のバージョン管理ス"
4967 "キームの一員です。英数字は、クレートのメタデータを表すハッシュ値です。"
4968
4969 #. type: Plain text
4970 #: src/doc/tutorial.md:3175
4971 #, fuzzy
4972 #| msgid "## The standard library"
4973 msgid "## The standard library and the prelude"
4974 msgstr "## 標準ライブラリ"
4975
4976 #. type: Plain text
4977 #: src/doc/tutorial.md:3187
4978 #, fuzzy
4979 #| msgid "~~~~ {.ignore} let foo = 10;"
4980 msgid "~~~ {.ignore} extern crate std; ~~~"
4981 msgstr ""
4982 "~~~~ {.ignore}\n"
4983 "let foo = 10;"
4984
4985 #. type: Plain text
4986 #: src/doc/tutorial.md:3193
4987 #, fuzzy
4988 #| msgid "~~~~ {.ignore} let foo = 10;"
4989 msgid "~~~ {.ignore} use std::prelude::*; ~~~"
4990 msgstr ""
4991 "~~~~ {.ignore}\n"
4992 "let foo = 10;"
4993
4994 #. type: Plain text
4995 #: src/doc/tutorial.md:3234
4996 #, fuzzy
4997 #| msgid "## The standard library"
4998 msgid "## The extra library"
4999 msgstr "## 標準ライブラリ"
5000
5001 #. type: Plain text
5002 #: src/doc/tutorial.md:3246
5003 msgid "# What next?"
5004 msgstr "# 次のステップは?"
5005
5006 #. type: Plain text
5007 #: src/doc/tutorial.md:3249
5008 #, fuzzy
5009 #| msgid ""
5010 #| "Now that you know the essentials, check out any of the additional "
5011 #| "tutorials on individual topics."
5012 msgid ""
5013 "Now that you know the essentials, check out any of the additional guides on "
5014 "individual topics."
5015 msgstr ""
5016 "Rust の本質的な部分に関する説明は以上です。個々のトピックにおける追加のチュー"
5017 "トリアルもチェックしてみてください。"
5018
5019 #. type: Bullet: '* '
5020 #: src/doc/tutorial.md:3260
5021 #, fuzzy
5022 #| msgid "[Containers and iterators](tutorial-container.html)"
5023 msgid "[Pointers][pointers]"
5024 msgstr "[コンテナとイテレータ](tutorial-container.html)"
5025
5026 #. type: Bullet: '* '
5027 #: src/doc/tutorial.md:3260
5028 #, fuzzy
5029 #| msgid "% The Rust Language Tutorial"
5030 msgid "[Lifetimes][lifetimes]"
5031 msgstr "% Rust 言語チュートリアル"
5032
5033 #. type: Bullet: '* '
5034 #: src/doc/tutorial.md:3260
5035 msgid "[Tasks and communication][tasks]"
5036 msgstr "[タスクと通信][tasks]"
5037
5038 #. type: Bullet: '* '
5039 #: src/doc/tutorial.md:3260
5040 msgid "[Macros][macros]"
5041 msgstr "[マクロ][macros]"
5042
5043 #. type: Bullet: '* '
5044 #: src/doc/tutorial.md:3260
5045 msgid "[The foreign function interface][ffi]"
5046 msgstr "[他言語間インターフェース (foreign function inferface)][ffi]"
5047
5048 #. type: Bullet: '* '
5049 #: src/doc/tutorial.md:3260
5050 #, fuzzy
5051 #| msgid "[Containers and iterators](tutorial-container.html)"
5052 msgid "[Containers and iterators][container]"
5053 msgstr "[コンテナとイテレータ](tutorial-container.html)"
5054
5055 #. type: Bullet: '* '
5056 #: src/doc/tutorial.md:3260
5057 #, fuzzy
5058 #| msgid "% The Rust Language Tutorial"
5059 msgid "[Testing Rust code][testing]"
5060 msgstr "% Rust 言語チュートリアル"
5061
5062 #. type: Bullet: '* '
5063 #: src/doc/tutorial.md:3260
5064 #, fuzzy
5065 #| msgid "% The Rust Language Tutorial"
5066 msgid "[The Rust Runtime][runtime]"
5067 msgstr "% Rust 言語チュートリアル"