@ -142,6 +142,26 @@ integrated development environments (IDEs) have built-in support for Rust. You
@@ -142,6 +142,26 @@ integrated development environments (IDEs) have built-in support for Rust. You
can always find a fairly current list of many editors and IDEs on [the tools
page][tools] on the Rust website.
### Working Offline with This Book
In several examples, we will use Rust packages beyond the standard library. To
work through those examples, you will either need to have an internet connection
or to have downloaded those dependencies ahead of time. To download the
dependencies ahead of time, you can run the following commands. (We’ll explain
what `cargo` is and what each of these commands does in detail later.)
```console
$ cargo new get-dependencies
$ cd get-dependencies
$ cargo add rand@0.8.5 trpl@0.2.0
```
This will cache the downloads for these packages so you will not need to
download them later. Once you have run this command, you do not need to keep the
`get-dependencies` folder. If you have run this command, you can use the
`--offline` flag with all `cargo` commands in the rest of the book to use these
cached versions instead of attempting to use the network.
@ -32,14 +32,13 @@ First, in Listing 16-6, we’ll create a channel but not do anything with it.
@@ -32,14 +32,13 @@ First, in Listing 16-6, we’ll create a channel but not do anything with it.
Note that this won’t compile yet because Rust can’t tell what type of values we
@ -109,8 +109,17 @@ It could also be that the browser is trying to connect to the server multiple
@@ -109,8 +109,17 @@ It could also be that the browser is trying to connect to the server multiple
times because the server isn’t responding with any data. When `stream` goes out
of scope and is dropped at the end of the loop, the connection is closed as
part of the `drop` implementation. Browsers sometimes deal with closed
connections by retrying, because the problem might be temporary. The important
factor is that we’ve successfully gotten a handle to a TCP connection!
connections by retrying, because the problem might be temporary.
Browsers also sometimes open multiple connections to the server without sending
any requests, so that if they *do* later send requests, they can happen faster.
When this happens, our server will see each connection, regardless of whether
there are any requests over that connection. Many versions of Chrome-based
browsers do this, for example; you can disable that optimization by using =
private browsing mode or use a different browser.
The important factor is that we’ve successfully gotten a handle to a TCP
connection!
Remember to stop the program by pressing <kbd>ctrl</kbd>-<kbd>c</kbd> when
you’re done running a particular version of the code. Then restart the program