Fixed line wrapping

This commit is contained in:
Carol (Nichols || Goulding) 2016-11-03 13:47:15 -04:00
parent e05538b247
commit a0f21b42b9
2 changed files with 17 additions and 6 deletions

View File

@ -86,7 +86,8 @@ mod client {
```
<caption>
Listing 7-1: The `network` module and the `client` module defined side-by-side in *src/lib.rs*
Listing 7-1: The `network` module and the `client` module defined side-by-side
in *src/lib.rs*
</caption>
Now we have a `network::connect` function and a `client::connect` function.
@ -178,7 +179,8 @@ mod network {
```
<caption>
Listing 7-3: Three modules, `client`, `network`, and `network::server` all defined in *src/lib.rs*
Listing 7-3: Three modules, `client`, `network`, and `network::server` all
defined in *src/lib.rs*
</caption>
which has this module hierarchy:
@ -318,7 +320,8 @@ fn connect() {
mod server;
```
Then create a `src/server.rs` file and enter the contents of the `server` module that we extracted:
Then create a `src/server.rs` file and enter the contents of the `server`
module that we extracted:
Filename: src/server.rs
@ -382,7 +385,8 @@ $ mv src/server.rs src/network
```
Now if we try to `cargo build`, compilation will work (we'll still have
warnings though). Our module layout still looks like this, which is exactly the same as it did when we had all the code in *src/lib.rs* in Listing 7-3:
warnings though). Our module layout still looks like this, which is exactly the
same as it did when we had all the code in *src/lib.rs* in Listing 7-3:
```text
communicator

View File

@ -1,6 +1,11 @@
## Controlling Visibility with `pub`
We resolved the error messages shown in Listing 7-4 by moving the `network` and `network::server` code into the *src/network/mod.rs* and *src/network/server.rs* files, respectively. At that point, `cargo build` was able to build our project, but we still get some warning messages about the `client::connect`, `network::connect`, and `network::server::connect` functions not being used:
We resolved the error messages shown in Listing 7-4 by moving the `network` and
`network::server` code into the *src/network/mod.rs* and
*src/network/server.rs* files, respectively. At that point, `cargo build` was
able to build our project, but we still get some warning messages about the
`client::connect`, `network::connect`, and `network::server::connect` functions
not being used:
```bash
warning: function is never used: `connect`, #[warn(dead_code)] on by default
@ -84,7 +89,9 @@ unused.
To tell Rust to make something public, we add the `pub` keyword to the start of
the declaration of the item we want to make public. We'll focus on fixing the
warning that tells us that `client::connect` has gone unused for now, as well as the "module `client` is private" error from our binary crate. Modify `src/lib.rs` to make the `client` module public, like so:
warning that tells us that `client::connect` has gone unused for now, as well
as the "module `client` is private" error from our binary crate. Modify
`src/lib.rs` to make the `client` module public, like so:
Filename: src/lib.rs