Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor text improvements #3790

Merged
merged 3 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/appendix-01-keywords.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The following list contains keywords that are reserved for current or future
use by the Rust language. As such, they cannot be used as identifiers (except
as raw identifiers as we’ll discuss in the “[Raw
as raw identifiers, as we’ll discuss in the “[Raw
Identifiers][raw-identifiers]<!-- ignore -->” section). Identifiers are names
of functions, variables, parameters, struct fields, modules, crates, constants,
macros, static values, attributes, types, traits, or lifetimes.
Expand Down Expand Up @@ -81,7 +81,7 @@ Rust for potential future use.
### Raw Identifiers

*Raw identifiers* are the syntax that lets you use keywords where they wouldn’t
normally be allowed. You use a raw identifier by prefixing a keyword with `r#`.
usually be allowed. You use a raw identifier by prefixing a keyword with `r#`.

For example, `match` is a keyword. If you try to compile the following function
that uses `match` as its name:
Expand All @@ -106,7 +106,7 @@ error: expected identifier, found keyword `match`

The error shows that you can’t use the keyword `match` as the function
identifier. To use `match` as a function name, you need to use the raw
identifier syntax, like this:
identifier syntax like this:

<span class="filename">Filename: src/main.rs</span>

Expand All @@ -121,11 +121,11 @@ fn main() {
```

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`.
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. This gives us more freedom to
choose identifier names, as well as lets us integrate with programs written in
choose identifier names and 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
Expand Down
4 changes: 2 additions & 2 deletions src/appendix-02-operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ locations.
| `"..."` | String literal |
| `r"..."`, `r#"..."#`, `r##"..."##`, etc. | Raw string literal, escape characters not processed |
| `b"..."` | Byte string literal; constructs an array of bytes instead of a string |
| `br"..."`, `br#"..."#`, `br##"..."##`, etc. | Raw byte string literal, combination of raw and byte string literal |
| `br"..."`, `br#"..."#`, `br##"..."##`, etc. | Raw byte string literal, a combination of raw and byte string literal |
| `'...'` | Character literal |
| `b'...'` | ASCII byte literal |
| <code>&vert;...&vert; expr</code> | Closure |
Expand Down Expand Up @@ -119,7 +119,7 @@ parameters.
| Symbol | Explanation |
|--------|-------------|
| `path<...>` | Specifies parameters to generic type in a type (e.g., `Vec<u8>`) |
| `path::<...>`, `method::<...>` | Specifies parameters to generic type, function, or method in an expression; often referred to as turbofish (e.g., `"42".parse::<i32>()`) |
| `path::<...>`, `method::<...>` | Specifies parameters to a generic type, function, or method in an expression; often referred to as turbofish (e.g., `"42".parse::<i32>()`) |
| `fn ident<...> ...` | Define generic function |
| `struct ident<...> ...` | Define generic structure |
| `enum ident<...> ...` | Define generic enumeration |
Expand Down
10 changes: 5 additions & 5 deletions src/appendix-03-derivable-traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ for each trait for details of how to manually implement them.
These traits listed here are the only ones defined by the standard library that
can be implemented on your types using `derive`. Other traits defined in the
standard library don’t have sensible default behavior, so it’s up to you to
implement them in the way that makes sense for what you’re trying to accomplish.
implement them in a way that makes sense for what you’re trying to accomplish.

An example of a trait that can’t be derived is `Display`, which handles
formatting for end users. You should always consider the appropriate way to
Expand All @@ -45,7 +45,7 @@ The `Debug` trait allows you to print instances of a type for debugging
purposes, so you and other programmers using your type can inspect an instance
at a particular point in a program’s execution.

The `Debug` trait is required, for example, in use of the `assert_eq!` macro.
The `Debug` trait is required, for example, in using the `assert_eq!` macro.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is a good grammatical fix.

This macro prints the values of instances given as arguments if the equality
assertion fails so programmers can see why the two instances weren’t equal.

Expand All @@ -71,14 +71,14 @@ number types: the implementation of floating point numbers states that two
instances of the not-a-number (`NaN`) value are not equal to each other.

An example of when `Eq` is required is for keys in a `HashMap<K, V>` so the
`HashMap<K, V>` can tell whether two keys are the same.
`HashMap<K, V>` can tell whether two keys are identical.

### `PartialOrd` and `Ord` for Ordering Comparisons

The `PartialOrd` trait allows you to compare instances of a type for sorting
purposes. A type that implements `PartialOrd` can be used with the `<`, `>`,
`<=`, and `>=` operators. You can only apply the `PartialOrd` trait to types
that also implement `PartialEq`.
that implement `PartialEq`.

Deriving `PartialOrd` implements the `partial_cmp` method, which returns an
`Option<Ordering>` that will be `None` when the values given don’t produce an
Expand Down Expand Up @@ -115,7 +115,7 @@ data. See the [“Ways Variables and Data Interact:
Clone”][ways-variables-and-data-interact-clone]<!-- ignore --> section in
Chapter 4 for more information on `Clone`.

Deriving `Clone` implements the `clone` method, which when implemented for the
Deriving `Clone` implements the `clone` method, which, when implemented for the
whole type, calls `clone` on each of the parts of the type. This means all the
fields or values in the type must also implement `Clone` to derive `Clone`.

Expand Down
9 changes: 4 additions & 5 deletions src/appendix-04-useful-development-tools.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Appendix D - Useful Development Tools

In this appendix, we talk about some useful development tools that the Rust
In this appendix, we talk about some useful development tools the Rust
project provides. We’ll look at automatic formatting, quick ways to apply
warning fixes, a linter, and integrating with IDEs.

Expand Down Expand Up @@ -32,8 +32,7 @@ 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 a clear 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 in a way you likely want. It’s likely you’ve seen compiler warnings before. For example,
consider this code:

<span class="filename">Filename: src/main.rs</span>
Expand Down Expand Up @@ -66,7 +65,7 @@ warning: unused variable: `i`
```

The warning suggests that we use `_i` as a name instead: the underscore
indicates that we intend for this variable to be unused. We can automatically
indicates that we intend this variable to be unused. We can automatically
apply that suggestion using the `rustfix` tool by running the command `cargo
fix`:

Expand Down Expand Up @@ -138,7 +137,7 @@ error: approximate value of `f{32, 64}::consts::PI` found
|
= note: `#[deny(clippy::approx_constant)]` on by default
= help: consider using the constant directly
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
= help: for further information, visit https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
```

This error lets you know that Rust already has a more precise `PI` constant
Expand Down
2 changes: 1 addition & 1 deletion src/appendix-05-editions.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Rust 2018, your project will compile and be able to use that dependency. The
opposite situation, where your project uses Rust 2018 and a dependency uses
Rust 2015, works as well.

To be clear: most features will be available on all editions. Developers using
To be clear: most features will be available in all editions. Developers using
any Rust edition will continue to see improvements as new stable releases are
made. However, in some cases, mainly when new keywords are added, some new
features might only be available in later editions. You will need to switch
Expand Down
7 changes: 3 additions & 4 deletions src/appendix-07-nightly-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ assume that the Rust team is working on the release of Rust 1.5. That release
happened in December of 2015, but it will provide us with realistic version
numbers. A new feature is added to Rust: a new commit lands on the `master`
branch. Each night, a new nightly version of Rust is produced. Every day is a
release day, and these releases are created by our release infrastructure
automatically. So as time passes, our releases look like this, once a night:
release day, and these releases are created automatically by our release infrastructure. So, as time passes, our releases look like this once a night:

```text
nightly: * - - * - - *
Expand All @@ -62,7 +61,7 @@ nightly: * - - * - - * - - * - - *
beta: *
```

Let’s say a regression is found. Good thing we had some time to test the beta
Let’s say a regression is found. It's a good thing we had some time to test the beta
release before the regression snuck into a stable release! The fix is applied
to `master`, so that nightly is fixed, and then the fix is backported to the
`beta` branch, and a new release of beta is produced:
Expand Down Expand Up @@ -106,7 +105,7 @@ release, you can know the date of the next one: it’s six weeks later. A nice
aspect of having releases scheduled every six weeks is that the next train is
coming soon. If a feature happens to miss a particular release, there’s no need
to worry: another one is happening in a short time! This helps reduce pressure
to sneak possibly unpolished features in close to the release deadline.
to sneak possibly unpolished features close to the release deadline.

Thanks to this process, you can always check out the next build of Rust and
verify for yourself that it’s easy to upgrade to: if a beta release doesn’t
Expand Down
30 changes: 15 additions & 15 deletions src/ch00-00-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ productive while writing systems-level code.

### Students

Rust is for students and those who are interested in learning about systems
Rust is for students and those interested in learning about systems
concepts. Using Rust, many people have learned about topics like operating
systems development. The community is very welcoming and happy to answer
student questions. Through efforts such as this book, the Rust teams want to
Expand All @@ -59,7 +59,7 @@ Hundreds of companies, large and small, use Rust in production for a variety of
tasks, including command line tools, web services, DevOps tooling, embedded
devices, audio and video analysis and transcoding, cryptocurrencies,
bioinformatics, search engines, Internet of Things applications, machine
learning, and even major parts of the Firefox web browser.
learning, and even significant parts of the Firefox web browser.

### Open Source Developers

Expand All @@ -72,7 +72,7 @@ language.
Rust is for people who crave speed and stability in a language. By speed, we
mean both how quickly Rust code can run and the speed at which Rust lets you
write programs. The Rust compiler’s checks ensure stability through feature
additions and refactoring. This is in contrast to the brittle legacy code in
additions and refactoring. This contrasts with the brittle legacy code in
languages without these checks, which developers are often afraid to modify. By
striving for zero-cost abstractions, higher-level features that compile to
lower-level code as fast as code written manually, Rust endeavors to make safe
Expand All @@ -88,14 +88,14 @@ Rust a try and see if its choices work for you.

This book assumes that you’ve written code in another programming language but
doesn’t make any assumptions about which one. We’ve tried to make the material
broadly accessible to those from a wide variety of programming backgrounds. We
don’t spend a lot of time talking about what programming *is* or how to think
broadly accessible to those from various programming backgrounds. We
don’t spend much time talking about what programming *is* or how to think
about it. If you’re entirely new to programming, you would be better served by
reading a book that specifically provides an introduction to programming.

## How to Use This Book

In general, this book assumes that you’re reading it in sequence from front to
Generally, this book assumes that you’re reading it in sequence from front to
back. Later chapters build on concepts in earlier chapters, and earlier
chapters might not delve into details on a particular topic but will revisit
the topic in a later chapter.
Expand Down Expand Up @@ -123,13 +123,13 @@ enums to make custom types in Rust.

In Chapter 7, you’ll learn about Rust’s module system and about privacy rules
for organizing your code and its public Application Programming Interface
(API). Chapter 8 discusses some common collection data structures that the
(API). Chapter 8 discusses common collection data structures the
standard library provides, such as vectors, strings, and hash maps. Chapter 9
explores Rust’s error-handling philosophy and techniques.

Chapter 10 digs into generics, traits, and lifetimes, which give you the power
to define code that applies to multiple types. Chapter 11 is all about testing,
which even with Rust’s safety guarantees is necessary to ensure your program’s
which, even with Rust’s safety guarantees, is necessary to ensure your program’s
logic is correct. In Chapter 12, we’ll build our own implementation of a subset
of functionality from the `grep` command line tool that searches for text
within files. For this, we’ll use many of the concepts we discussed in the
Expand All @@ -142,11 +142,11 @@ Chapter 15 discusses smart pointers that the standard library provides and the
traits that enable their functionality.

In Chapter 16, we’ll walk through different models of concurrent programming
and talk about how Rust helps you to program in multiple threads fearlessly.
and talk about how Rust helps you program in multiple threads fearlessly.
Chapter 17 looks at how Rust idioms compare to object-oriented programming
principles you might be familiar with.

Chapter 18 is a reference on patterns and pattern matching, which are powerful
Chapter 18 references patterns and pattern matching, which are powerful
ways of expressing ideas throughout Rust programs. Chapter 19 contains a
smorgasbord of advanced topics of interest, including unsafe Rust, macros, and
more about lifetimes, traits, types, functions, and closures.
Expand All @@ -159,7 +159,7 @@ more reference-like format. Appendix A covers Rust’s keywords, Appendix B
covers Rust’s operators and symbols, Appendix C covers derivable traits
provided by the standard library, Appendix D covers some useful development
tools, and Appendix E explains Rust editions. In Appendix F, you can find
translations of the book, and in Appendix G we’ll cover how Rust is made and
translations of the book, and in Appendix G, we’ll cover how Rust is made and
what nightly Rust is.

There is no wrong way to read this book: if you want to skip ahead, go for it!
Expand All @@ -168,13 +168,13 @@ confusion. But do whatever works for you.

<span id="ferris"></span>

An important part of the process of learning Rust is learning how to read the
error messages the compiler displays: these will guide you toward working code.
As such, we’ll provide many examples that don’t compile along with the error
An important aspect of mastering Rust involves understanding how to interpret the
error messages displayed by the compiler: these will guide you toward working code.
As such, we’ll provide many examples that don’t compile, along with the error
message the compiler will show you in each situation. Know that if you enter
and run a random example, it may not compile! Make sure you read the
surrounding text to see whether the example you’re trying to run is meant to
error. Ferris will also help you distinguish code that isn’t meant to work:
be an error. Ferris will also help you distinguish code that isn’t meant to work:

| Ferris | Meaning |
|------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
Expand Down
8 changes: 4 additions & 4 deletions src/ch01-01-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The following steps install the latest stable version of the Rust compiler.
Rust’s stability guarantees ensure that all the examples in the book that
compile will continue to compile with newer Rust versions. The output might
differ slightly between versions because Rust often improves error messages and
warnings. In other words, any newer, stable version of Rust you install using
warnings. In other words, any more recent stable version of Rust you install using
these steps should work as expected with the content of this book.

> ### Command Line Notation
Expand Down Expand Up @@ -39,7 +39,7 @@ for your password. If the install is successful, the following line will appear:
Rust is installed now. Great!
```

You will also need a *linker*, which is a program that Rust uses to join its
You will also need a *linker*, which is a program Rust uses to combine its
compiled outputs into one file. It is likely you already have one. If you get
linker errors, you should install a C compiler, which will typically include a
linker. A C compiler is also useful because some common Rust packages depend on
Expand Down Expand Up @@ -83,7 +83,7 @@ $ rustc --version
```

You should see the version number, commit hash, and commit date for the latest
stable version that has been released, in the following format:
stable version that has been released in the following format:

```text
rustc x.y.z (abcabcabc yyyy-mm-dd)
Expand Down Expand Up @@ -111,7 +111,7 @@ In Linux and macOS, use:
$ echo $PATH
```

If that’s all correct and Rust still isn’t working, there are a number of
If that’s all correct and Rust still isn’t working, there are several
places you can get help. Find out how to get in touch with other Rustaceans (a
silly nickname we call ourselves) on [the community page][community].

Expand Down
8 changes: 4 additions & 4 deletions src/ch01-02-hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ first line declares a function named `main` that has no parameters and returns
nothing. If there were parameters, they would go inside the parentheses `()`.

The function body is wrapped in `{}`. Rust requires curly brackets around all
function bodies. It’s good style to place the opening curly bracket on the same
function bodies. It’s a good style to place the opening curly bracket on the same
line as the function declaration, adding one space in between.

> Note: If you want to stick to a standard style across Rust projects, you can
> use an automatic formatter tool called `rustfmt` to format your code in a
> use an automatic formatting tool called `rustfmt` to format your code in a
> particular style (more on `rustfmt` in
> [Appendix D][devtools]<!-- ignore -->). The Rust team has included this tool
> with the standard Rust distribution, as `rustc` is, so it should already be
Expand All @@ -121,7 +121,7 @@ The body of the `main` function holds the following code:
This line does all the work in this little program: it prints text to the
screen. There are four important details to notice here.

First, Rust style is to indent with four spaces, not a tab.
First, the Rust style is to indent with four spaces, not a tab.

Second, `println!` calls a Rust macro. If it had called a function instead, it
would be entered as `println` (without the `!`). We’ll discuss Rust macros in
Expand Down Expand Up @@ -161,7 +161,7 @@ main main.rs
```

On Linux and macOS, you’ll see two files. With PowerShell on Windows, you’ll
see the same three files that you would see using CMD. With CMD on Windows, you
see the same three files you would see using CMD. With CMD on Windows, you
would enter the following:

```cmd
Expand Down