mirror of
https://github.com/rust-lang/book.git
synced 2026-04-06 04:24:44 -04:00
Propagate tech review edits to appendices to src
This commit is contained in:
@@ -15,18 +15,17 @@ The following is a list of keywords currently in use, with their functionality
|
||||
described.
|
||||
|
||||
* `as` - perform primitive casting, disambiguate the specific trait containing
|
||||
an item, or rename items in `use` and `extern crate` statements
|
||||
an item, or rename items in `use` statements
|
||||
* `async` - return a `Future` instead of blocking the current thread
|
||||
* `await` - suspend execution until the result of a `Future` is ready
|
||||
* `break` - exit a loop immediately
|
||||
* `const` - define constant items or constant raw pointers
|
||||
* `continue` - continue to the next loop iteration
|
||||
* `crate` - link an external crate or a macro variable representing the crate in
|
||||
which the macro is defined
|
||||
* `crate` - in a module path, refers to the crate root
|
||||
* `dyn` - dynamic dispatch to a trait object
|
||||
* `else` - fallback for `if` and `if let` control flow constructs
|
||||
* `enum` - define an enumeration
|
||||
* `extern` - link an external crate, function, or variable
|
||||
* `extern` - link an external function or variable
|
||||
* `false` - Boolean false literal
|
||||
* `fn` - define a function or the function pointer type
|
||||
* `for` - loop over items from an iterator, implement a trait, or specify a
|
||||
@@ -51,7 +50,8 @@ described.
|
||||
* `trait` - define a trait
|
||||
* `true` - Boolean true literal
|
||||
* `type` - define a type alias or associated type
|
||||
* `union` - define a [union] and is only a keyword when used in a union declaration
|
||||
* `union` - define a [union][union]<!-- ignore -->; is only a keyword when used
|
||||
in a union declaration
|
||||
* `unsafe` - denote unsafe code, functions, traits, or implementations
|
||||
* `use` - bring symbols into scope
|
||||
* `where` - denote clauses that constrain a type
|
||||
@@ -124,9 +124,11 @@ This code will compile without any errors. Note the `r#` prefix on the function
|
||||
name in its definition as well as where the function is called in `main`.
|
||||
|
||||
Raw identifiers allow you to use any word you choose as an identifier, even if
|
||||
that word happens to be a reserved keyword. In addition, raw identifiers allow
|
||||
you to use libraries written in a different Rust edition than your crate uses.
|
||||
For example, `try` isn’t a keyword in the 2015 edition but is in the 2018
|
||||
that word happens to be a reserved keyword. This gives us more freedom to
|
||||
choose identifier names, as well as lets us integrate with programs written in
|
||||
a language where these words aren’t keywords. In addition, raw identifiers
|
||||
allow you to use libraries written in a different Rust edition than your crate
|
||||
uses. For example, `try` isn’t a keyword in the 2015 edition but is in the 2018
|
||||
edition. If you depend on a library that’s written using the 2015 edition and
|
||||
has a `try` function, you’ll need to use the raw identifier syntax, `r#try` in
|
||||
this case, to call that function from your 2018 edition code. See [Appendix
|
||||
|
||||
@@ -32,8 +32,8 @@ on `rustfmt`, see [its documentation][rustfmt].
|
||||
### Fix Your Code with `rustfix`
|
||||
|
||||
The rustfix tool is included with Rust installations and can automatically fix
|
||||
compiler warnings that have one way to correct the problem that’s likely what
|
||||
you want. It’s likely you’ve seen compiler warnings before. For example,
|
||||
compiler warnings that have a clear way to correct the problem that’s likely
|
||||
what you want. It’s likely you’ve seen compiler warnings before. For example,
|
||||
consider this code:
|
||||
|
||||
<span class="filename">Filename: src/main.rs</span>
|
||||
|
||||
Reference in New Issue
Block a user