Skip to content

Commit 8f0c9a2

Browse files
authored
Merge pull request #2352 from rust-lang/console-highlighting
text -> console
2 parents 1e7000e + d44317c commit 8f0c9a2

File tree

61 files changed

+200
-199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+200
-199
lines changed

src/appendix-04-useful-development-tools.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ style to use when writing Rust: everyone formats their code using the tool.
1212

1313
To install `rustfmt`, enter the following:
1414

15-
```text
15+
```console
1616
$ rustup component add rustfmt
1717
```
1818

1919
This command gives you `rustfmt` and `cargo-fmt`, similar to how Rust gives you
2020
both `rustc` and `cargo`. To format any Cargo project, enter the following:
2121

22-
```text
22+
```console
2323
$ cargo fmt
2424
```
2525

@@ -50,7 +50,7 @@ fn main() {
5050
Here, we’re calling the `do_something` function 100 times, but we never use the
5151
variable `i` in the body of the `for` loop. Rust warns us about that:
5252

53-
```text
53+
```console
5454
$ cargo build
5555
Compiling myprogram v0.1.0 (file:///projects/myprogram)
5656
warning: unused variable: `i`
@@ -69,7 +69,7 @@ indicates that we intend for this variable to be unused. We can automatically
6969
apply that suggestion using the `rustfix` tool by running the command `cargo
7070
fix`:
7171

72-
```text
72+
```console
7373
$ cargo fix
7474
Checking myprogram v0.1.0 (file:///projects/myprogram)
7575
Fixing src/main.rs (1 fix)
@@ -103,13 +103,13 @@ common mistakes and improve your Rust code.
103103

104104
To install Clippy, enter the following:
105105

106-
```text
106+
```console
107107
$ rustup component add clippy
108108
```
109109

110110
To run Clippy’s lints on any Cargo project, enter the following:
111111

112-
```text
112+
```console
113113
$ cargo clippy
114114
```
115115

@@ -171,7 +171,7 @@ such as [the Rust plug-in for Visual Studio Code][vscode].
171171

172172
To install the `rls`, enter the following:
173173

174-
```text
174+
```console
175175
$ rustup component add rls
176176
```
177177

src/appendix-07-nightly-rust.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Rustup makes it easy to change between different release channels of Rust, on a
141141
global or per-project basis. By default, you’ll have stable Rust installed. To
142142
install nightly, for example:
143143

144-
```text
144+
```console
145145
$ rustup toolchain install nightly
146146
```
147147

@@ -162,7 +162,7 @@ nightly on a specific project, because you care about a cutting-edge feature.
162162
To do so, you can use `rustup override` in that project’s directory to set the
163163
nightly toolchain as the one `rustup` should use when you’re in that directory:
164164

165-
```text
165+
```console
166166
$ cd ~/projects/needs-nightly
167167
$ rustup override set nightly
168168
```

src/ch01-01-installation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ using these steps should work as expected with the content of this book.
2727

2828
If you’re using Linux or macOS, open a terminal and enter the following command:
2929

30-
```text
30+
```console
3131
$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
3232
```
3333

@@ -67,14 +67,14 @@ If there are specific differences, we’ll explain which to use.
6767
After you’ve installed Rust via `rustup`, updating to the latest version is
6868
easy. From your shell, run the following update script:
6969

70-
```text
70+
```console
7171
$ rustup update
7272
```
7373

7474
To uninstall Rust and `rustup`, run the following uninstall script from your
7575
shell:
7676

77-
```text
77+
```console
7878
$ rustup self uninstall
7979
```
8080

@@ -83,7 +83,7 @@ $ rustup self uninstall
8383
To check whether you have Rust installed correctly, open a shell and enter this
8484
line:
8585

86-
```text
86+
```console
8787
$ rustc --version
8888
```
8989

src/ch01-02-hello-world.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ and a directory for the “Hello, world!” project within the *projects* direct
2424

2525
For Linux, macOS, and PowerShell on Windows, enter this:
2626

27-
```text
27+
```console
2828
$ mkdir ~/projects
2929
$ cd ~/projects
3030
$ mkdir hello_world
@@ -62,7 +62,7 @@ fn main() {
6262
Save the file and go back to your terminal window. On Linux or macOS, enter
6363
the following commands to compile and run the file:
6464

65-
```text
65+
```console
6666
$ rustc main.rs
6767
$ ./main
6868
Hello, world!
@@ -143,7 +143,7 @@ Before running a Rust program, you must compile it using the Rust compiler by
143143
entering the `rustc` command and passing it the name of your source file, like
144144
this:
145145

146-
```text
146+
```console
147147
$ rustc main.rs
148148
```
149149

@@ -174,7 +174,7 @@ This shows the source code file with the *.rs* extension, the executable file
174174
Windows, a file containing debugging information with the *.pdb* extension.
175175
From here, you run the *main* or *main.exe* file, like this:
176176

177-
```text
177+
```console
178178
$ ./main # or .\main.exe on Windows
179179
```
180180

src/ch01-03-hello-cargo.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ used the official installers discussed in the
1818
through some other means, check whether Cargo is installed by entering the
1919
following into your terminal:
2020

21-
```text
21+
```console
2222
$ cargo --version
2323
```
2424

@@ -33,7 +33,7 @@ original “Hello, world!” project. Navigate back to your *projects* directory
3333
wherever you decided to store your code). Then, on any operating system, run
3434
the following:
3535

36-
```text
36+
```console
3737
$ cargo new hello_cargo
3838
$ cd hello_cargo
3939
```
@@ -124,7 +124,7 @@ Now let’s look at what’s different when we build and run the “Hello, world
124124
program with Cargo! From your *hello_cargo* directory, build your project by
125125
entering the following command:
126126

127-
```text
127+
```console
128128
$ cargo build
129129
Compiling hello_cargo v0.1.0 (file:///projects/hello_cargo)
130130
Finished dev [unoptimized + debuginfo] target(s) in 2.85 secs
@@ -134,7 +134,7 @@ This command creates an executable file in *target/debug/hello_cargo* (or
134134
*target\debug\hello_cargo.exe* on Windows) rather than in your current
135135
directory. You can run the executable with this command:
136136

137-
```text
137+
```console
138138
$ ./target/debug/hello_cargo # or .\target\debug\hello_cargo.exe on Windows
139139
Hello, world!
140140
```
@@ -150,7 +150,7 @@ We just built a project with `cargo build` and ran it with
150150
`./target/debug/hello_cargo`, but we can also use `cargo run` to compile the
151151
code and then run the resulting executable all in one command:
152152

153-
```text
153+
```console
154154
$ cargo run
155155
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
156156
Running `target/debug/hello_cargo`
@@ -162,7 +162,7 @@ Notice that this time we didn’t see output indicating that Cargo was compiling
162162
the binary. If you had modified your source code, Cargo would have rebuilt the
163163
project before running it, and you would have seen this output:
164164

165-
```text
165+
```console
166166
$ cargo run
167167
Compiling hello_cargo v0.1.0 (file:///projects/hello_cargo)
168168
Finished dev [unoptimized + debuginfo] target(s) in 0.33 secs
@@ -173,7 +173,7 @@ Hello, world!
173173
Cargo also provides a command called `cargo check`. This command quickly checks
174174
your code to make sure it compiles but doesn’t produce an executable:
175175

176-
```text
176+
```console
177177
$ cargo check
178178
Checking hello_cargo v0.1.0 (file:///projects/hello_cargo)
179179
Finished dev [unoptimized + debuginfo] target(s) in 0.32 secs
@@ -222,7 +222,7 @@ tooling you’ll use in the rest of your Rust career. In fact, to work on any
222222
existing projects, you can use the following commands to check out the code
223223
using Git, change to that project’s directory, and build:
224224

225-
```text
225+
```console
226226
$ git clone someurl.com/someproject
227227
$ cd someproject
228228
$ cargo build

src/ch02-00-guessing-game-tutorial.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ correct, the game will print a congratulatory message and exit.
1717
To set up a new project, go to the *projects* directory that you created in
1818
Chapter 1 and make a new project using Cargo, like so:
1919

20-
```text
20+
```console
2121
$ cargo new guessing_game
2222
$ cd guessing_game
2323
```
@@ -49,7 +49,7 @@ you. Check out the *src/main.rs* file:
4949
Now let’s compile this “Hello, world!” program and run it in the same step
5050
using the `cargo run` command:
5151

52-
```text
52+
```console
5353
{{#include ../listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/output.txt}}
5454
```
5555

@@ -260,7 +260,7 @@ entered into standard input.
260260

261261
If you don’t call `expect`, the program will compile, but you’ll get a warning:
262262

263-
```text
263+
```console
264264
{{#include ../listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/output.txt}}
265265
```
266266

@@ -306,7 +306,7 @@ cargo clean
306306
cargo run
307307
input 6 -->
308308

309-
```text
309+
```console
310310
$ cargo run
311311
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
312312
Finished dev [unoptimized + debuginfo] target(s) in 6.44s
@@ -375,7 +375,7 @@ cd listings/ch02-guessing-game-tutorial/listing-02-02/
375375
cargo clean
376376
cargo build -->
377377

378-
```text
378+
```console
379379
$ cargo build
380380
Updating crates.io index
381381
Downloaded rand v0.5.5
@@ -426,7 +426,7 @@ cd listings/ch02-guessing-game-tutorial/listing-02-02/
426426
touch src/main.rs
427427
cargo build -->
428428

429-
```text
429+
```console
430430
$ cargo build
431431
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
432432
Finished dev [unoptimized + debuginfo] target(s) in 2.53 secs
@@ -474,7 +474,7 @@ cargo update
474474
assuming there is a new 0.5.x version of rand; otherwise use another update
475475
as a guide to creating the hypothetical output shown here -->
476476

477-
```text
477+
```console
478478
$ cargo update
479479
Updating crates.io index
480480
Updating rand v0.5.5 -> v0.5.6
@@ -555,7 +555,7 @@ cargo run
555555
5
556556
-->
557557

558-
```text
558+
```console
559559
$ cargo run
560560
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
561561
Finished dev [unoptimized + debuginfo] target(s) in 2.53s
@@ -633,7 +633,7 @@ expression ends because it has no need to look at the last arm in this scenario.
633633

634634
However, the code in Listing 2-4 won’t compile yet. Let’s try it:
635635

636-
```text
636+
```console
637637
{{#include ../listings/ch02-guessing-game-tutorial/listing-02-04/output.txt}}
638638
```
639639

@@ -717,7 +717,7 @@ cargo run
717717
76
718718
-->
719719

720-
```text
720+
```console
721721
$ cargo run
722722
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
723723
Finished dev [unoptimized + debuginfo] target(s) in 0.43s
@@ -771,7 +771,7 @@ cargo run
771771
quit
772772
-->
773773

774-
```text
774+
```console
775775
$ cargo run
776776
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
777777
Finished dev [unoptimized + debuginfo] target(s) in 1.50s
@@ -863,7 +863,7 @@ foo
863863
(correct guess)
864864
-->
865865

866-
```text
866+
```console
867867
$ cargo run
868868
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
869869
Running `target/debug/guessing_game`

src/ch03-01-variables-and-mutability.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ code with the following code that won’t compile just yet:
2323
Save and run the program using `cargo run`. You should receive an error
2424
message, as shown in this output:
2525

26-
```text
26+
```console
2727
{{#include ../listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/output.txt}}
2828
```
2929

@@ -65,7 +65,7 @@ For example, let’s change *src/main.rs* to the following:
6565

6666
When we run the program now, we get this:
6767

68-
```text
68+
```console
6969
{{#include ../listings/ch03-common-programming-concepts/no-listing-02-adding-mut/output.txt}}
7070
```
7171

@@ -147,7 +147,7 @@ repeating `let x =`, taking the original value and adding `1` so the value of
147147
previous value by `2` to give `x` a final value of `12`. When we run this
148148
program, it will output the following:
149149

150-
```text
150+
```console
151151
{{#include ../listings/ch03-common-programming-concepts/no-listing-03-shadowing/output.txt}}
152152
```
153153

@@ -180,7 +180,7 @@ try to use `mut` for this, as shown here, we’ll get a compile-time error:
180180

181181
The error says we’re not allowed to mutate a variable’s type:
182182

183-
```text
183+
```console
184184
{{#include ../listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/output.txt}}
185185
```
186186

src/ch03-02-data-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ If we don’t add the type annotation here, Rust will display the following
2020
error, which means the compiler needs more information from us to know which
2121
type we want to use:
2222

23-
```text
23+
```console
2424
{{#include ../listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/output.txt}}
2525
```
2626

@@ -326,7 +326,7 @@ compile but exit with an error when it runs:
326326

327327
Running this code using `cargo run` produces the following result:
328328

329-
```text
329+
```console
330330
{{#include ../listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/output.txt}}
331331
```
332332

0 commit comments

Comments
 (0)