mirror of
https://github.com/rust-lang/book.git
synced 2026-05-16 20:51:10 -04:00
fancy quotes
This commit is contained in:
@@ -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 Identifiers][raw-identifiers]"
|
||||
as raw identifiers as we’ll discuss in the “[Raw Identifiers][raw-identifiers]”
|
||||
section), including names of functions, variables, parameters, struct fields,
|
||||
modules, crates, constants, macros, static values, attributes, types, traits,
|
||||
or lifetimes.
|
||||
@@ -98,7 +98,7 @@ error: expected identifier, found keyword `match`
|
||||
| ^^^^^ expected identifier, found keyword
|
||||
```
|
||||
|
||||
The error says that you can't use the keyword `match` as the function
|
||||
The error says that you can’t use the keyword `match` as the function
|
||||
identifier. You can use `match` as a function name by using a raw identifier:
|
||||
|
||||
<span class="filename">Filename: src/main.rs</span>
|
||||
|
||||
@@ -151,7 +151,7 @@ If you have a C or C++ background, you’ll notice that this is similar to `gcc`
|
||||
or `clang`. After compiling successfully, Rust outputs a binary executable.
|
||||
|
||||
On Linux, macOS, and PowerShell on Windows, you can see the executable by
|
||||
entering the `ls` command in your shell. On Linux and macOS, you'll see two
|
||||
entering the `ls` command in your shell. 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.
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ let mut bar = 5; // mutable
|
||||
> line. Rust ignores everything in comments, which are discussed in more detail
|
||||
> in Chapter 3.
|
||||
|
||||
Let's return to the guessing game program. You now know that `let mut guess`
|
||||
Let’s return to the guessing game program. You now know that `let mut guess`
|
||||
will introduce a mutable variable named `guess`. On the other side of the equal
|
||||
sign (`=`) is the value that `guess` is bound to, which is the result of
|
||||
calling `String::new`, a function that returns a new instance of a `String`.
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
The first parts of the module system we’ll cover are *packages* and *crates*. A
|
||||
*crate* is a binary or library. The *crate root* is a source file that the Rust
|
||||
compiler starts from and makes up the root module of your crate (we’ll explain
|
||||
modules in depth in the section ["Defining Modules to Control Scope and
|
||||
Privacy"][modules]<!-- ignore -->). A *package* is one or more crates that
|
||||
modules in depth in the section [“Defining Modules to Control Scope and
|
||||
Privacy”][modules]<!-- ignore -->). A *package* is one or more crates that
|
||||
provide a set of functionality. A package contains a *Cargo.toml* file that
|
||||
describes how to build those crates.
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ elements in a vector</span>
|
||||
To change the value that the mutable reference refers to, we have to use the
|
||||
dereference operator (`*`) to get to the value in `i` before we can use the
|
||||
`+=` operator. We’ll talk more about the dereference operator in the
|
||||
["Following the Pointer to the Value with the Dereference Operator"][deref]
|
||||
[“Following the Pointer to the Value with the Dereference Operator”][deref]
|
||||
section of Chapter 15.
|
||||
|
||||
### Using an Enum to Store Multiple Types
|
||||
|
||||
@@ -81,7 +81,7 @@ bug in their code so they can fix it during development. Similarly, `panic!` is
|
||||
often appropriate if you’re calling external code that is out of your control
|
||||
and it returns an invalid state that you have no way of fixing.
|
||||
|
||||
However, when failure is expected, it's more appropriate to return a `Result`
|
||||
However, when failure is expected, it’s more appropriate to return a `Result`
|
||||
than to make a `panic!` call. Examples include a parser being given malformed
|
||||
data or an HTTP request returning a status that indicates you have hit a rate
|
||||
limit. In these cases, returning a `Result` indicates that failure is an
|
||||
|
||||
@@ -58,7 +58,7 @@ First, we add another `use` statement to bring in a relevant part of the
|
||||
standard library: we need `std::fs` to handle files.
|
||||
|
||||
In `main`, we’ve added a new statement: `fs::read_to_string` takes the
|
||||
`filename`, opens that file, and returns a `Result<String>` of the file's
|
||||
`filename`, opens that file, and returns a `Result<String>` of the file’s
|
||||
contents.
|
||||
|
||||
After that statement, we’ve again added a temporary `println!` statement that
|
||||
|
||||
@@ -657,7 +657,7 @@ fn main() {
|
||||
*src/main.rs*</span>
|
||||
|
||||
We add a `use minigrep::Config` line to bring the `Config` type from the
|
||||
library crate into the binary crate's scope, and we prefix the `run` function
|
||||
library crate into the binary crate’s scope, and we prefix the `run` function
|
||||
with our crate name. Now all the functionality should be connected and should
|
||||
work. Run the program with `cargo run` and make sure everything works
|
||||
correctly.
|
||||
|
||||
@@ -14,7 +14,7 @@ smart pointers to work in a similar way as references. Then we’ll look at
|
||||
Rust’s *deref coercion* feature and how it lets us work with either references
|
||||
or smart pointers.
|
||||
|
||||
> Note: there's one big difference between the `MyBox<T>` type we're about to
|
||||
> Note: there’s one big difference between the `MyBox<T>` type we’re about to
|
||||
> build and the real `Box<T>`: our version will not store its data on the heap.
|
||||
> We are focusing this example on `Deref`, so where the data is actually stored
|
||||
> is less important than the pointer-like behavior.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Welcome to The Rust Programming Language book! This version of the text assumes
|
||||
you are using Rust 1.31.0 or later, with `edition="2018"` in *Cargo.toml* of
|
||||
all projects to use Rust 2018 Edition idioms. See the ["Installation" section
|
||||
all projects to use Rust 2018 Edition idioms. See the [“Installation” section
|
||||
of Chapter 1][install]<!-- ignore --> to install or update Rust, and see
|
||||
[Appendix E][editions]<!-- ignore --> for information on what editions of Rust
|
||||
are.
|
||||
|
||||
Reference in New Issue
Block a user