File tree 4 files changed +58
-4
lines changed
4 files changed +58
-4
lines changed Original file line number Diff line number Diff line change 196
196
- [ Integration testing] ( testing/integration_testing.md )
197
197
- [ Dev-dependencies] ( testing/dev_dependencies.md )
198
198
199
+ - [ Unsafe Operations] ( unsafe.md )
200
+
201
+ - [ Compatibility] ( compatibility.md )
202
+ - [ Raw identifiers] ( compatibility/raw_identifiers.md )
203
+
199
204
- [ Meta] ( meta.md )
200
205
- [ Documentation] ( meta/doc.md )
201
-
202
- - [ Unsafe Operations] ( unsafe.md )
Original file line number Diff line number Diff line change
1
+ # Compatibility
2
+
3
+ The Rust language is fastly evolving, and because of this certain compatibility
4
+ issues can arise, despite efforts to ensure forwards-compatibility wherever
5
+ possible.
6
+
7
+ * [ Raw identifiers] ( compatibility/raw_identifiers.md )
Original file line number Diff line number Diff line change
1
+ # Raw identifiers
2
+
3
+ Rust, like many programming languages, has the concept of "keywords".
4
+ These identifiers mean something to the language, and so you cannot use them in
5
+ places like variable names, function names, and other places.
6
+ Raw identifiers let you use keywords where they would not normally be allowed.
7
+ This is particularly useful when Rust introduces new keywords, and a library
8
+ using an older edition of Rust has a variable or function with the same name
9
+ as a keyword introduced in a newer edition.
10
+
11
+ For example, consider a crate ` foo ` compiled with the 2015 edition of Rust that
12
+ exports a function named ` try ` . This keyword is reserved for a new feature in
13
+ the 2018 edition, so without raw identifiers, we would have no way to name the
14
+ function.
15
+
16
+ ``` rust,ignore
17
+ extern crate foo;
18
+
19
+ fn main() {
20
+ foo::try();
21
+ }
22
+ ```
23
+
24
+ You'll get this error:
25
+
26
+ ``` text
27
+ error: expected identifier, found keyword `try`
28
+ --> src/main.rs:4:4
29
+ |
30
+ 4 | foo::try();
31
+ | ^^^ expected identifier, found keyword
32
+ ```
33
+
34
+ You can write this with a raw identifier:
35
+
36
+ ``` rust,ignore
37
+ extern crate foo;
38
+
39
+ fn main() {
40
+ foo::r#try();
41
+ }
42
+ ```
Original file line number Diff line number Diff line change @@ -51,10 +51,12 @@ Now let's begin!
51
51
52
52
- [ Testing] ( testing.html ) - All sorts of testing in Rust.
53
53
54
- - [ Meta] ( meta.html ) - Documentation, Benchmarking.
55
-
56
54
- [ Unsafe Operations] ( unsafe.html )
57
55
56
+ - [ Compatibility] ( compatibility.html )
57
+
58
+ - [ Meta] ( meta.html ) - Documentation, Benchmarking.
59
+
58
60
59
61
[ rust ] : https://www.rust-lang.org/
60
62
[ install ] : https://www.rust-lang.org/install.html
You can’t perform that action at this time.
0 commit comments