1
+ <!--
1
2
# Raw identifiers
3
+ -->
4
+ # 生識別子
2
5
6
+ <!--
3
7
Rust, like many programming languages, has the concept of "keywords".
4
8
These identifiers mean something to the language, and so you cannot use them in
5
9
places like variable names, function names, and other places.
6
10
Raw identifiers let you use keywords where they would not normally be allowed.
7
11
This is particularly useful when Rust introduces new keywords, and a library
8
12
using an older edition of Rust has a variable or function with the same name
9
13
as a keyword introduced in a newer edition.
14
+ -->
15
+ Rustは多くのプログラミング言語と同様に、「キーワード」の概念を持っています。
16
+ これらの識別子は言語にとって何かしらの意味を持ちますので、変数名や関数名、その他の場所で使用することはできません。
17
+ 生識別子は、通常は許されない状況でキーワードを使用することを可能にします。
18
+ これは、新しいキーワードを導入したRustと、古いエディションのRustを使用したライブラリが同じ名前の変数や関数を持つ場合に特に便利です。
10
19
20
+ <!--
11
21
For example, consider a crate `foo` compiled with the 2015 edition of Rust that
12
22
exports a function named `try`. This keyword is reserved for a new feature in
13
23
the 2018 edition, so without raw identifiers, we would have no way to name the
14
24
function.
25
+ -->
26
+ 例えば、2015年エディションのRustでコンパイルされたクレート` foo ` が` try ` という名前の関数をエクスポートしているとします。
27
+ このキーワードは2018年エディションで新機能として予約されていますので、生識別子がなければ、この関数を名付ける方法がありません。
28
+
15
29
16
30
``` rust,ignore
17
31
extern crate foo;
@@ -21,7 +35,10 @@ fn main() {
21
35
}
22
36
```
23
37
38
+ <!--
24
39
You'll get this error:
40
+ -->
41
+ このエラーが出ます:
25
42
26
43
``` text
27
44
error: expected identifier, found keyword `try`
@@ -31,7 +48,10 @@ error: expected identifier, found keyword `try`
31
48
| ^^^ expected identifier, found keyword
32
49
```
33
50
51
+ <!--
34
52
You can write this with a raw identifier:
53
+ -->
54
+ これは生識別子を使って書くことができます:
35
55
36
56
``` rust,ignore
37
57
extern crate foo;
0 commit comments