Skip to content

text -> console #2352

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

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 7 additions & 7 deletions src/appendix-04-useful-development-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ style to use when writing Rust: everyone formats their code using the tool.

To install `rustfmt`, enter the following:

```text
```console
$ rustup component add rustfmt
```

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

```text
```console
$ cargo fmt
```

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

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

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

To install Clippy, enter the following:

```text
```console
$ rustup component add clippy
```

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

```text
```console
$ cargo clippy
```

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

To install the `rls`, enter the following:

```text
```console
$ rustup component add rls
```

Expand Down
4 changes: 2 additions & 2 deletions src/appendix-07-nightly-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Rustup makes it easy to change between different release channels of Rust, on a
global or per-project basis. By default, you’ll have stable Rust installed. To
install nightly, for example:

```text
```console
$ rustup toolchain install nightly
```

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

```text
```console
$ cd ~/projects/needs-nightly
$ rustup override set nightly
```
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 @@ -27,7 +27,7 @@ using these steps should work as expected with the content of this book.

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

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

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

```text
```console
$ rustup update
```

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

```text
```console
$ rustup self uninstall
```

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

```text
```console
$ rustc --version
```

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 @@ -24,7 +24,7 @@ and a directory for the “Hello, world!” project within the *projects* direct

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

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

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

```text
```console
$ rustc main.rs
```

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

```text
```console
$ ./main # or .\main.exe on Windows
```

Expand Down
16 changes: 8 additions & 8 deletions src/ch01-03-hello-cargo.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ used the official installers discussed in the
through some other means, check whether Cargo is installed by entering the
following into your terminal:

```text
```console
$ cargo --version
```

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

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

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

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

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

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

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

```text
```console
$ git clone someurl.com/someproject
$ cd someproject
$ cargo build
Expand Down
24 changes: 12 additions & 12 deletions src/ch02-00-guessing-game-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ correct, the game will print a congratulatory message and exit.
To set up a new project, go to the *projects* directory that you created in
Chapter 1 and make a new project using Cargo, like so:

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

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

Expand Down Expand Up @@ -260,7 +260,7 @@ entered into standard input.

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

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

Expand Down Expand Up @@ -306,7 +306,7 @@ cargo clean
cargo run
input 6 -->

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

```text
```console
$ cargo build
Updating crates.io index
Downloaded rand v0.5.5
Expand Down Expand Up @@ -426,7 +426,7 @@ cd listings/ch02-guessing-game-tutorial/listing-02-02/
touch src/main.rs
cargo build -->

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

```text
```console
$ cargo update
Updating crates.io index
Updating rand v0.5.5 -> v0.5.6
Expand Down Expand Up @@ -555,7 +555,7 @@ cargo run
5
-->

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

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

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

Expand Down Expand Up @@ -717,7 +717,7 @@ cargo run
76
-->

```text
```console
$ cargo run
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
Finished dev [unoptimized + debuginfo] target(s) in 0.43s
Expand Down Expand Up @@ -771,7 +771,7 @@ cargo run
quit
-->

```text
```console
$ cargo run
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
Finished dev [unoptimized + debuginfo] target(s) in 1.50s
Expand Down Expand Up @@ -863,7 +863,7 @@ foo
(correct guess)
-->

```text
```console
$ cargo run
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
Running `target/debug/guessing_game`
Expand Down
8 changes: 4 additions & 4 deletions src/ch03-01-variables-and-mutability.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ code with the following code that won’t compile just yet:
Save and run the program using `cargo run`. You should receive an error
message, as shown in this output:

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

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

When we run the program now, we get this:

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

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

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

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions src/ch03-02-data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If we don’t add the type annotation here, Rust will display the following
error, which means the compiler needs more information from us to know which
type we want to use:

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

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

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

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

Expand Down
Loading