@@ -183,8 +183,10 @@ Table B-1: Operators
183183| ` - ` | ` - expr ` | Arithmetic negation| ` Neg ` |
184184| ` - ` | ` expr - expr ` | Arithmetic subtraction| ` Sub ` |
185185| ` -= ` | ` var -= expr ` | Arithmetic subtraction and assignment| ` SubAssign ` |
186- | ` -> ` | ` fn(...) -> type ` , <code >\| …\| -> type</code >| Function and closure return type||
187- | ` . ` | ` expr.ident ` | Member access||
186+ | ` -> ` | ` fn(...) -> type ` , <code >\| ...\| -> type</code >| Function and closure return type||
187+ | ` . ` | ` expr.ident ` | Field access||
188+ | ` . ` | ` expr.ident(expr, ...) ` | Method call||
189+ | ` . ` | ` expr.0 ` , ` expr.1 ` , etc.| Tuple indexing||
188190| ` .. ` | ` .. ` , ` expr.. ` , ` ..expr ` , ` expr..expr ` | Right-exclusive range literal| ` PartialOrd ` |
189191| ` ..= ` | ` ..=expr ` , ` expr..=expr ` | Right-inclusive range literal| ` PartialOrd ` |
190192| ` .. ` | ` ..expr ` | Struct literal update syntax||
@@ -230,14 +232,14 @@ Table B-2: Stand-Alone Syntax
230232| Symbol| Explanation|
231233| ------| -----------|
232234| ` 'ident ` | Named lifetime or loop label|
233- | ` ... u8` , ` ... i32` , ` ... f64` , ` ... usize` , etc. | Numeric literal of specific type|
235+ | Digits immediately followed by ` u8 ` , ` i32 ` , ` f64 ` , ` usize ` , and so on | Numeric literal of specific type|
234236| ` "..." ` | String literal|
235237| ` r"..." ` , ` r#"..."# ` , ` r##"..."## ` , etc.| Raw string literal, escape characters not processed|
236238| ` b"..." ` | Byte string literal; constructs an array of bytes instead of a string|
237239| ` br"..." ` , ` br#"..."# ` , ` br##"..."## ` , etc.| Raw byte string literal, combination of raw and byte string literal|
238240| ` '...' ` | Character literal|
239241| ` b'...' ` | ASCII byte literal|
240- | <code >\| … \| expr</code >| Closure|
242+ | <code >\| ... \| expr</code >| Closure|
241243| ` ! ` | Always empty bottom type for diverging functions|
242244| ` _ ` | “Ignored” pattern binding; also used to make integer literals readable|
243245
@@ -298,8 +300,8 @@ Table B-6: Macros and Attributes
298300| ` #[meta] ` | Outer attribute|
299301| ` #![meta] ` | Inner attribute|
300302| ` $ident ` | Macro substitution|
301- | ` $ident:kind ` | Macro capture |
302- | ` $(…)… ` | Macro repetition|
303+ | ` $ident:kind ` | Macro metavariable |
304+ | ` $(...)... ` | Macro repetition|
303305| ` ident!(...) ` , ` ident!{...} ` , ` ident![...] ` | Macro invocation|
304306
305307Table B-7 shows symbols that create comments.
@@ -315,9 +317,9 @@ Table B-7: Comments
315317| ` /*!...*/ ` | Inner block doc comment|
316318| ` /**...*/ ` | Outer block doc comment|
317319
318- Table B-8 shows symbols that appear in the context of using tuples .
320+ Table B-8 shows the contexts in which parentheses are used .
319321
320- Table B-8: Tuples
322+ Table B-8: Parentheses
321323
322324| Symbol| Explanation|
323325| ------| -----------|
@@ -328,7 +330,6 @@ Table B-8: Tuples
328330| ` (expr, ...) ` | Tuple expression|
329331| ` (type, ...) ` | Tuple type|
330332| ` expr(expr, ...) ` | Function call expression; also used to initialize tuple ` struct ` s and tuple ` enum ` variants|
331- | ` expr.0 ` , ` expr.1 ` , etc.| Tuple indexing|
332333
333334Table B-9 shows the contexts in which curly braces are used.
334335
@@ -337,7 +338,7 @@ Table B-9: Curly Brackets
337338| Context| Explanation|
338339| -------| -----------|
339340| ` {...} ` | Block expression|
340- | ` Type {...} ` | ` struct ` literal|
341+ | ` Type {...} ` | Struct literal|
341342
342343Table B-10 shows the contexts in which square brackets are used.
343344
@@ -542,14 +543,11 @@ The `rustfmt` tool reformats your code according to the community code style.
542543Many collaborative projects use ` rustfmt ` to prevent arguments about which
543544style to use when writing Rust: everyone formats their code using the tool.
544545
545- To install ` rustfmt ` , enter the following:
546-
547- ```
548- $ rustup component add rustfmt
549- ```
550-
551- This command gives you ` rustfmt ` and ` cargo-fmt ` , similar to how Rust gives you
552- both ` rustc ` and ` cargo ` . To format any Cargo project, enter the following:
546+ Rust installations include ` rustfmt ` by default, so you should already have the
547+ programs ` rustfmt ` and ` cargo-fmt ` on your system. These two commands are
548+ analogous to ` rustc ` and ` cargo ` in that ` rustfmt ` allows finer-grained control
549+ and ` cargo-fmt ` understands conventions of a project that uses Cargo. To format
550+ any Cargo project, enter the following:
553551
554552```
555553$ cargo fmt
@@ -561,9 +559,9 @@ on `rustfmt`, see its documentation at *https://github.com/rust-lang/rustfmt*.
561559
562560### Fix Your Code with rustfix
563561
564- The rustfix tool is included with Rust installations and can automatically fix
562+ The ` rustfix ` tool is included with Rust installations and can automatically fix
565563compiler warnings that have a clear way to correct the problem that’s likely
566- what you want. It’s likely you’ve seen compiler warnings before. For example,
564+ what you want. You’ve probably seen compiler warnings before. For example,
567565consider this code:
568566
569567Filename: src/main.rs
@@ -575,8 +573,8 @@ fn main() {
575573}
576574```
577575
578- Here, we’re defining variable ` x ` as mutable, but we never actually mutate it.
579- Rust warns us about that:
576+ Here, we’re defining the variable ` x ` as mutable, but we never actually mutate
577+ it. Rust warns us about that:
580578
581579```
582580$ cargo build
@@ -614,21 +612,16 @@ fn main() {
614612}
615613```
616614
617- The ` x ` variable is now immutable, and the warning no longer appears.
615+ The variable ` x ` is now immutable, and the warning no longer appears.
618616
619617You can also use the ` cargo fix ` command to transition your code between
620618different Rust editions. Editions are covered in Appendix E at * appendix-05-editions.md* .
621619
622620### More Lints with Clippy
623621
624622The Clippy tool is a collection of lints to analyze your code so you can catch
625- common mistakes and improve your Rust code.
626-
627- To install Clippy, enter the following:
628-
629- ```
630- $ rustup component add clippy
631- ```
623+ common mistakes and improve your Rust code. Clippy is included with standard
624+ Rust installations.
632625
633626To run Clippy’s lints on any Cargo project, enter the following:
634627
@@ -639,7 +632,7 @@ $ cargo clippy
639632For example, say you write a program that uses an approximation of a
640633mathematical constant, such as pi, as this program does:
641634
642- Filename: src/main.rs
635+ src/main.rs
643636
644637```
645638fn main() {
@@ -649,6 +642,8 @@ fn main() {
649642}
650643```
651644
645+
646+
652647Running ` cargo clippy ` on this project results in this error:
653648
654649```
@@ -665,10 +660,11 @@ error: approximate value of `f{32, 64}::consts::PI` found
665660
666661This error lets you know that Rust already has a more precise ` PI ` constant
667662defined, and that your program would be more correct if you used the constant
668- instead. You would then change your code to use the ` PI ` constant. The
669- following code doesn’t result in any errors or warnings from Clippy:
663+ instead. You would then change your code to use the ` PI ` constant.
670664
671- Filename: src/main.rs
665+ The following code doesn’t result in any errors or warnings from Clippy:
666+
667+ src/main.rs
672668
673669```
674670fn main() {
@@ -678,19 +674,21 @@ fn main() {
678674}
679675```
680676
677+
678+
681679For more information on Clippy, see its documentation at * https://github.com/rust-lang/rust-clippy * .
682680
683681### IDE Integration Using rust-analyzer
684682
685- To help IDE integration, the Rust community recommends using
683+ To help with IDE integration, the Rust community recommends using
686684` rust-analyzer ` . This tool is a set of
687- compiler-centric utilities that speaks the Language Server Protocol, which is a specification for IDEs and programming languages to
685+ compiler-centric utilities that speak Language Server Protocol, which is a specification for IDEs and programming languages to
688686communicate with each other. Different clients can use ` rust-analyzer ` , such as
689687the Rust analyzer plug-in for Visual Studio Code at * https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer * .
690688
691689Visit the ` rust-analyzer ` project’s home page
692690for installation instructions, then install the language server support in your
693- particular IDE. Your IDE will gain abilities such as autocompletion, jump to
691+ particular IDE. Your IDE will gain capabilities such as autocompletion, jump to
694692definition, and inline errors.
695693
696694## Appendix E - Editions
0 commit comments