diff --git a/listings/ch14-more-about-cargo/output-only-02-add-one/add/Cargo.toml b/listings/ch14-more-about-cargo/output-only-02-add-one/add/Cargo.toml
index 8d9f501247..28af3b3b70 100644
--- a/listings/ch14-more-about-cargo/output-only-02-add-one/add/Cargo.toml
+++ b/listings/ch14-more-about-cargo/output-only-02-add-one/add/Cargo.toml
@@ -1,3 +1,3 @@
[workspace]
resolver = "3"
-members = [ "add_one","adder"]
+members = ["add_one", "adder"]
diff --git a/nostarch/chapter14.md b/nostarch/chapter14.md
index 6d263aa1cb..fb2491d04f 100644
--- a/nostarch/chapter14.md
+++ b/nostarch/chapter14.md
@@ -8,9 +8,9 @@ directory, so all fixes need to be made in `/src/`.
# More About Cargo and Crates.io
-So far we’ve used only the most basic features of Cargo to build, run, and test
-our code, but it can do a lot more. In this chapter, we’ll discuss some of its
-other, more advanced features to show you how to do the following:
+So far, we’ve used only the most basic features of Cargo to build, run, and
+test our code, but it can do a lot more. In this chapter, we’ll discuss some of
+its other, more advanced features to show you how to do the following:
* Customize your build through release profiles
* Publish libraries on crates.io
@@ -28,7 +28,7 @@ different configurations that allow a programmer to have more control over
various options for compiling code. Each profile is configured independently of
the others.
-Cargo has two main profiles: the `dev` profile Cargo uses when you run `cargo build` and the `release` profile Cargo uses when you run `cargo build --release`. The `dev` profile is defined with good defaults for development,
+Cargo has two main profiles: the `dev` profile Cargo uses when you run `cargo build`, and the `release` profile Cargo uses when you run `cargo build --release`. The `dev` profile is defined with good defaults for development,
and the `release` profile has good defaults for release builds.
These profile names might be familiar from the output of your builds:
@@ -68,7 +68,7 @@ opt-level = 3
The `opt-level` setting controls the number of optimizations Rust will apply to
your code, with a range of 0 to 3. Applying more optimizations extends
compiling time, so if you’re in development and compiling your code often,
-you’ll want fewer optimizations to compile faster even if the resulting code
+you’ll want fewer optimizations to compile faster even if the resultant code
runs slower. The default `opt-level` for `dev` is therefore `0`. When you’re
ready to release your code, it’s best to spend more time compiling. You’ll only
compile in release mode once, but you’ll run the compiled program many times,
@@ -154,7 +154,7 @@ For convenience, running `cargo doc --open` will build the HTML for your
current crate’s documentation (as well as the documentation for all of your
crate’s dependencies) and open the result in a web browser. Navigate to the
`add_one` function and you’ll see how the text in the documentation comments is
-rendered, as shown in Figure 14-1:
+rendered, as shown in Figure 14-1.
@@ -189,7 +189,8 @@ how to use your library, and doing so has an additional bonus: running `cargo te
better than documentation with examples. But nothing is worse than examples
that don’t work because the code has changed since the documentation was
written. If we run `cargo test` with the documentation for the `add_one`
-function from Listing 14-1, we will see a section in the test results like this:
+function from Listing 14-1, we will see a section in the test results that looks
+like this:
@@ -486,17 +486,17 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
error: failed to publish to registry at https://crates.io
Caused by:
- the remote server responded with an error (status 400 Bad Request): missing or empty metadata fields: description, license. Please see https://doc.rust-lang.org/cargo/reference/manifest.html for more information on configuring these field
+ the remote server responded with an error (status 400 Bad Request): missing or empty metadata fields: description, license. Please see https://doc.rust-lang.org/cargo/reference/manifest.html for more information on configuring these fields
```
-This errors because you’re missing some crucial information: a description and
-license are required so people will know what your crate does and under what
-terms they can use it. In *Cargo.toml*, add a description that’s just a
-sentence or two, because it will appear with your crate in search results. For
-the `license` field, you need to give a *license identifier value*. The Linux
-Foundation’s Software Package Data Exchange (SPDX) at *http://spdx.org/licenses/* lists the identifiers
-you can use for this value. For example, to specify that you’ve licensed your
-crate using the MIT License, add the `MIT` identifier:
+This results in an error because you’re missing some crucial information: a
+description and license are required so people will know what your crate does
+and under what terms they can use it. In *Cargo.toml*, add a description that’s
+just a sentence or two, because it will appear with your crate in search
+results. For the `license` field, you need to give a *license identifier value*.
+The Linux Foundation’s Software Package Data Exchange (SPDX) at *https://spdx.org/licenses/* lists the
+identifiers you can use for this value. For example, to specify that you’ve
+licensed your crate using the MIT License, add the `MIT` identifier:
Filename: Cargo.toml
@@ -526,7 +526,7 @@ Filename: Cargo.toml
[package]
name = "guessing_game"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
description = "A fun game where you guess what number the computer has chosen."
license = "MIT OR Apache-2.0"
@@ -534,8 +534,8 @@ license = "MIT OR Apache-2.0"
```
Cargo’s documentation at *https://doc.rust-lang.org/cargo/* describes other
-metadata you can specify to ensure others can discover and use your crate more
-easily.
+metadata you can specify to ensure that others can discover and use your crate
+more easily.
### Publishing to Crates.io
@@ -545,9 +545,9 @@ Publishing a crate uploads a specific version to
crates.io for others to use.
Be careful, because a publish is *permanent*. The version can never be
-overwritten, and the code cannot be deleted. One major goal of
-crates.io is to act as a permanent archive
-of code so that builds of all projects that depend on crates from
+overwritten, and the code cannot be deleted except in certain circumstances.
+One major goal of Crates.io is to act as a permanent archive of code so that
+builds of all projects that depend on crates from
crates.io will continue to work. Allowing
version deletions would make fulfilling that goal impossible. However, there is
no limit to the number of crate versions you can publish.
@@ -564,11 +564,17 @@ copy just the relevant lines below
$ cargo publish
Updating crates.io index
Packaging guessing_game v0.1.0 (file:///projects/guessing_game)
+ Packaged 6 files, 1.2KiB (895.0B compressed)
Verifying guessing_game v0.1.0 (file:///projects/guessing_game)
Compiling guessing_game v0.1.0
(file:///projects/guessing_game/target/package/guessing_game-0.1.0)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.19s
Uploading guessing_game v0.1.0 (file:///projects/guessing_game)
+ Uploaded guessing_game v0.1.0 to registry `crates-io`
+note: waiting for `guessing_game v0.1.0` to be available at registry
+`crates-io`.
+You may press ctrl-c to skip waiting; the crate should be available shortly.
+ Published guessing_game v0.1.0 at registry `crates-io`
```
Congratulations! You’ve now shared your code with the Rust community, and
@@ -578,8 +584,8 @@ anyone can easily add your crate as a dependency of their project.
When you’ve made changes to your crate and are ready to release a new version,
you change the `version` value specified in your *Cargo.toml* file and
-republish. Use the Semantic Versioning rules at *http://semver.org/* to decide what an
-appropriate next version number is based on the kinds of changes you’ve made.
+republish. Use the Semantic Versioning rules at *https://semver.org/* to decide what an
+appropriate next version number is, based on the kinds of changes you’ve made.
Then run `cargo publish` to upload the new version.
@@ -591,9 +597,9 @@ Then run `cargo publish` to upload the new version.
Although you can’t remove previous versions of a crate, you can prevent any
future projects from adding them as a new dependency. This is useful when a
crate version is broken for one reason or another. In such situations, Cargo
-supports *yanking* a crate version.
+supports yanking a crate version.
-Yanking a version prevents new projects from depending on that version while
+*Yanking* a version prevents new projects from depending on that version while
allowing all existing projects that depend on it to continue. Essentially, a
yank means that all projects with a *Cargo.lock* will not break, and any future
*Cargo.lock* files generated will not use the yanked version.
@@ -643,7 +649,7 @@ can concentrate on the structure of the workspace. There are multiple ways to
structure a workspace, so we’ll just show one common way. We’ll have a
workspace containing a binary and two libraries. The binary, which will provide
the main functionality, will depend on the two libraries. One library will
-provide an `add_one` function, and a second library an `add_two` function.
+provide an `add_one` function and the other library an `add_two` function.
These three crates will be part of the same workspace. We’ll start by creating
a new directory for the workspace:
@@ -657,13 +663,13 @@ configure the entire workspace. This file won’t have a `[package]` section.
Instead, it will start with a `[workspace]` section that will allow us to add
members to the workspace. We also make a point to use the latest and greatest
version of Cargo’s resolver algorithm in our workspace by setting the
-`resolver` to `"2"`.
+`resolver` value to `"3"`.
Filename: Cargo.toml
```
[workspace]
-resolver = "2"
+resolver = "3"
```
Next, we’ll create the `adder` binary crate by running `cargo new` within the
@@ -671,6 +677,7 @@ Next, we’ll create the `adder` binary crate by running `cargo new` within the
@@ -1053,7 +1063,8 @@ binary target, or both.
All binaries installed with `cargo install` are stored in the installation
root’s *bin* folder. If you installed Rust using *rustup.rs* and don’t have any
custom configurations, this directory will be *$HOME/.cargo/bin*. Ensure that
-directory is in your `$PATH`to be able to run programs you’ve installed with`cargo install`.
+directory is in your `$PATH` to be able to run programs you’ve installed with
+`cargo install`.
For example, in Chapter 12 we mentioned that there’s a Rust implementation of
the `grep` tool called `ripgrep` for searching files. To install `ripgrep`, we
@@ -1066,29 +1077,29 @@ cargo install something you don't have, copy relevant output below
```
$ cargo install ripgrep
Updating crates.io index
- Downloaded ripgrep v13.0.0
- Downloaded 1 crate (243.3 KB) in 0.88s
- Installing ripgrep v13.0.0
+ Downloaded ripgrep v14.1.1
+ Downloaded 1 crate (213.6 KB) in 0.40s
+ Installing ripgrep v14.1.1
--snip--
- Compiling ripgrep v13.0.0
- Finished `release` profile [optimized + debuginfo] target(s) in 10.64s
+ Compiling grep v0.3.2
+ Finished `release` profile [optimized + debuginfo] target(s) in 6.73s
Installing ~/.cargo/bin/rg
- Installed package `ripgrep v13.0.0` (executable `rg`)
+ Installed package `ripgrep v14.1.1` (executable `rg`)
```
The second-to-last line of the output shows the location and the name of the
installed binary, which in the case of `ripgrep` is `rg`. As long as the
installation directory is in your `$PATH`, as mentioned previously, you can
-then run `rg --help` and start using a faster, rustier tool for searching files!
+then run `rg --help` and start using a faster, Rustier tool for searching files!
## Extending Cargo with Custom Commands
Cargo is designed so you can extend it with new subcommands without having to
-modify Cargo. If a binary in your `$PATH` is named `cargo-something`, you can
-run it as if it was a Cargo subcommand by running `cargo something`. Custom
+modify it. If a binary in your `$PATH` is named `cargo-something`, you can run
+it as if it were a Cargo subcommand by running `cargo something`. Custom
commands like this are also listed when you run `cargo --list`. Being able to
use `cargo install` to install extensions and then run them just like the
-built-in Cargo tools is a super convenient benefit of Cargo’s design!
+built-in Cargo tools is a super-convenient benefit of Cargo’s design!
## Summary
diff --git a/nostarch/docx/chapter14.docx b/nostarch/docx/chapter14.docx
index c256f41730..e586986faa 100644
Binary files a/nostarch/docx/chapter14.docx and b/nostarch/docx/chapter14.docx differ
diff --git a/src/ch14-00-more-about-cargo.md b/src/ch14-00-more-about-cargo.md
index a6d0d91549..4d99fedf8c 100644
--- a/src/ch14-00-more-about-cargo.md
+++ b/src/ch14-00-more-about-cargo.md
@@ -1,8 +1,8 @@
# More About Cargo and Crates.io
-So far we’ve used only the most basic features of Cargo to build, run, and test
-our code, but it can do a lot more. In this chapter, we’ll discuss some of its
-other, more advanced features to show you how to do the following:
+So far, we’ve used only the most basic features of Cargo to build, run, and
+test our code, but it can do a lot more. In this chapter, we’ll discuss some of
+its other, more advanced features to show you how to do the following:
- Customize your build through release profiles
- Publish libraries on [crates.io](https://crates.io/)
diff --git a/src/ch14-01-release-profiles.md b/src/ch14-01-release-profiles.md
index 387298332e..20c20fce6e 100644
--- a/src/ch14-01-release-profiles.md
+++ b/src/ch14-01-release-profiles.md
@@ -6,7 +6,7 @@ various options for compiling code. Each profile is configured independently of
the others.
Cargo has two main profiles: the `dev` profile Cargo uses when you run `cargo
-build` and the `release` profile Cargo uses when you run `cargo build
+build`, and the `release` profile Cargo uses when you run `cargo build
--release`. The `dev` profile is defined with good defaults for development,
and the `release` profile has good defaults for release builds.
diff --git a/src/ch14-02-publishing-to-crates-io.md b/src/ch14-02-publishing-to-crates-io.md
index 3437e8e520..03c4f23199 100644
--- a/src/ch14-02-publishing-to-crates-io.md
+++ b/src/ch14-02-publishing-to-crates-io.md
@@ -45,7 +45,7 @@ For convenience, running `cargo doc --open` will build the HTML for your
current crate’s documentation (as well as the documentation for all of your
crate’s dependencies) and open the result in a web browser. Navigate to the
`add_one` function and you’ll see how the text in the documentation comments is
-rendered, as shown in Figure 14-1:
+rendered, as shown in Figure 14-1.
@@ -100,20 +100,20 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
```
Now, if we change either the function or the example so the `assert_eq!` in the
-example panics and run `cargo test` again, we’ll see that the doc tests catch
+example panics, and run `cargo test` again, we’ll see that the doc tests catch
that the example and the code are out of sync with each other!
#### Commenting Contained Items
-The style of doc comment `//!` adds documentation to the item that contains the
-comments rather than to the items following the comments. We typically use
+The style of doc comment `//!` adds documentation to the item that *contains*
+the comments rather than to the items *following* the comments. We typically use
these doc comments inside the crate root file (_src/lib.rs_ by convention) or
inside a module to document the crate or the module as a whole.
For example, to add documentation that describes the purpose of the `my_crate`
crate that contains the `add_one` function, we add documentation comments that
start with `//!` to the beginning of the _src/lib.rs_ file, as shown in Listing
-14-2:
+14-2.
@@ -194,7 +194,7 @@ see them.
Another crate that depends on this library would need `use` statements that
bring the items from `art` into scope, specifying the module structure that’s
currently defined. Listing 14-4 shows an example of a crate that uses the
-`PrimaryColor` and `mix` items from the `art` crate:
+`PrimaryColor` and `mix` items from the `art` crate.