8
8
The following list contains keywords that are reserved for current or future
9
9
use by the Rust language. As such, they cannot be used as identifiers (except
10
10
as raw identifiers as we’ll discuss in the “[Raw
11
- Identifiers][raw-identifiers]” section), including names of
12
- functions, variables, parameters, struct fields, modules, crates, constants,
11
+ Identifiers][raw-identifiers]” section). Identifiers are names
12
+ of functions, variables, parameters, struct fields, modules, crates, constants,
13
13
macros, static values, attributes, types, traits, or lifetimes.
14
14
-->
15
15
16
16
以下のリストは、現在、あるいは将来Rust言語により使用されるために予約されているキーワードです。
17
- そのため、識別子として使用することはできません。識別子には、関数名、変数名、引数名、構造体のフィールド名、モジュール名、クレート名、定数名、マクロ名、静的な値の名前、属性名、型名、トレイト名、ライフタイム名などがあります 。
18
- ただし、 [ 生識別子 ] [ raw-identifiers ] のところで議論する生識別子は例外です 。
17
+ そのため、識別子として使用することはできません(ただし、 [ 生識別子 ] [ raw-identifiers ] のところで議論する生識別子は例外です) 。
18
+ 識別子とは、関数、変数、引数、構造体のフィールド、モジュール、クレート、定数、マクロ、静的な値、属性、型、トレイト、またはライフタイムの名前です 。
19
19
20
20
[ raw-identifiers ] : #raw-identifiers
21
21
@@ -26,25 +26,25 @@ macros, static values, attributes, types, traits, or lifetimes.
26
26
### 現在使用されているキーワード
27
27
28
28
<!--
29
- The following keywords currently have the functionality described.
29
+ The following is a list of keywords currently in use, with their functionality
30
+ described.
30
31
-->
31
32
32
- 以下のキーワードは、解説された通りの機能が現状あります 。
33
+ 以下は現在使用されているキーワードと、その機能の一覧です 。
33
34
34
35
<!--
35
36
* `as` - perform primitive casting, disambiguate the specific trait containing
36
- an item, or rename items in `use` and `extern crate` statements
37
+ an item, or rename items in `use` statements
37
38
* `async` - return a `Future` instead of blocking the current thread
38
39
* `await` - suspend execution until the result of a `Future` is ready
39
40
* `break` - exit a loop immediately
40
41
* `const` - define constant items or constant raw pointers
41
42
* `continue` - continue to the next loop iteration
42
- * `crate` - link an external crate or a macro variable representing the crate in
43
- which the macro is defined
43
+ * `crate` - in a module path, refers to the crate root
44
44
* `dyn` - dynamic dispatch to a trait object
45
45
* `else` - fallback for `if` and `if let` control flow constructs
46
46
* `enum` - define an enumeration
47
- * `extern` - link an external crate, function, or variable
47
+ * `extern` - link an external function or variable
48
48
* `false` - Boolean false literal
49
49
* `fn` - define a function or the function pointer type
50
50
* `for` - loop over items from an iterator, implement a trait, or specify a
@@ -69,7 +69,8 @@ The following keywords currently have the functionality described.
69
69
* `trait` - define a trait
70
70
* `true` - Boolean true literal
71
71
* `type` - define a type alias or associated type
72
- * `union` - define a [union] and is only a keyword when used in a union declaration
72
+ * `union` - define a [union][union]; is only a keyword when used
73
+ in a union declaration
73
74
* `unsafe` - denote unsafe code, functions, traits, or implementations
74
75
* `use` - bring symbols into scope
75
76
* `where` - denote clauses that constrain a type
@@ -82,16 +83,16 @@ The following keywords currently have the functionality described.
82
83
higher-ranked lifetimeについては議論の余地ありか
83
84
-->
84
85
85
- * ` as ` - 基礎的なキャストの実行、要素を含む特定のトレイトの明確化、` use ` や ` extern crate ` 文の要素名を変更する
86
+ * ` as ` - 基礎的なキャストの実行、要素を含む特定のトレイトの明確化、` use ` 文の要素名を変更する
86
87
* ` async ` - 現在のスレッドをブロックする代わりに` Future ` を返す
87
88
* ` await ` - ` Future ` の結果が準備できるまで実行を停止する
88
89
* ` break ` - 即座にループを抜ける
89
90
* ` const ` - 定数要素か定数の生ポインタを定義する
90
91
* ` continue ` - 次のループの繰り返しに継続する
91
- * ` crate ` - 外部のクレートかマクロが定義されているクレートを表すマクロ変数をリンクする
92
+ * ` crate ` - モジュールパス内で、クレートルートを表す
92
93
* ` else ` - ` if ` と` if let ` 制御フロー構文の規定
93
94
* ` enum ` - 列挙型を定義する
94
- * ` extern ` - 外部のクレート、関数 、変数をリンクする
95
+ * ` extern ` - 外部の関数 、変数をリンクする
95
96
* ` false ` - bool型のfalseリテラル
96
97
* ` fn ` - 関数か関数ポインタ型を定義する
97
98
* ` for ` - イテレータの要素を繰り返す、トレイトの実装、高階ライフタイムの指定
@@ -115,6 +116,7 @@ higher-ranked lifetimeについては議論の余地ありか
115
116
* ` trait ` - トレイトを定義する
116
117
* ` true ` - bool型のtrueリテラル
117
118
* ` type ` - 型エイリアスか関連型を定義する
119
+ * ` union ` - [ 共用体] [ union ] を定義する; 共用体宣言内で使用される場合のみキーワードです
118
120
* ` unsafe ` - unsafeなコード、関数、トレイト、実装に言及する
119
121
* ` use ` - スコープにシンボルを持ち込む
120
122
* ` where ` - 型を制限する節に言及する
@@ -129,11 +131,11 @@ higher-ranked lifetimeについては議論の余地ありか
129
131
### 将来的な使用のために予約されているキーワード
130
132
131
133
<!--
132
- The following keywords do not have any functionality but are reserved by Rust
133
- for potential future use.
134
+ The following keywords do not yet have any functionality but are reserved by
135
+ Rust for potential future use.
134
136
-->
135
137
136
- 以下のキーワードには機能が何もないものの 、将来的に使用される可能性があるので、Rustにより予約されています。
138
+ 以下のキーワードにはまだ機能が何もないものの 、将来的に使用される可能性があるので、Rustにより予約されています。
137
139
138
140
<!--
139
141
* `abstract`
@@ -243,15 +245,18 @@ name in its definition as well as where the function is called in `main`.
243
245
244
246
<!--
245
247
Raw identifiers allow you to use any word you choose as an identifier, even if
246
- that word happens to be a reserved keyword. In addition, raw identifiers allow
247
- you to use libraries written in a different Rust edition than your crate uses.
248
- For example, `try` isn’t a keyword in the 2015 edition but is in the 2018
248
+ that word happens to be a reserved keyword. This gives us more freedom to
249
+ choose identifier names, as well as lets us integrate with programs written in
250
+ a language where these words aren’t keywords. In addition, raw identifiers
251
+ allow you to use libraries written in a different Rust edition than your crate
252
+ uses. For example, `try` isn’t a keyword in the 2015 edition but is in the 2018
249
253
edition. If you depend on a library that’s written using the 2015 edition and
250
254
has a `try` function, you’ll need to use the raw identifier syntax, `r#try` in
251
255
this case, to call that function from your 2018 edition code. See [Appendix
252
256
E][appendix-e] for more information on editions.
253
257
-->
254
258
生識別子を使えば、仮にそれが予約されたキーワードであろうとも、任意の単語を識別子として使えるようになります。
259
+ これにより識別子名の選択により大きな自由が与えられ、これらの単語がキーワードではない言語で書かれたプログラムとの統合も可能になります。
255
260
更に、あなたのクレートが使っているRustのeditionとは異なるeditionで書かれたライブラリを呼び出すこともできるようになります。
256
261
たとえば、` try ` は2015 editionではキーワードではありませんでしたが、2018 editionではキーワードです。
257
262
もし、2015 editionで書かれており、` try ` 関数を持っているライブラリに依存している場合、あなたの2018 editionのコードからその関数を呼び出すためには、生識別子構文を使う必要がでてくるでしょう。今回なら` r#try ` ですね。
0 commit comments