Cargo explanation confusing in official Rust book

In the last weeks, I read nearly all of the official rust book, and recently additional the fine summary from A half-hour to learn Rust

Still, a few sections of the book are confusing to me. One is the following, where the one sentence "Otherwise, by default, Cargo will only look for versions greater than 0.8.5 and less than 0.9.0." makes no sense to me. With removing this sentence, all is clear and easily understandable. Is this sentence a bug? I read that section multiple times (as a non native speaker, but with that sentence it remains confusing. Most problematic is the start with "Otherwise", but "by default" does not make much sense as well. Unfortunately, the GitHub issue tracker of the book is inactive currently, so I hesitated to create an issue. Here is that problematic section from the book -- I made that sentence italic:

Updating a Crate to Get a New Version

When you do want to update a crate, Cargo provides the command update, which will ignore the Cargo.lock file and figure out all the latest versions that fit your specifications in Cargo.toml. Cargo will then write those versions to the Cargo.lock file. Otherwise, by default, Cargo will only look for versions greater than 0.8.5 and less than 0.9.0. If the rand crate has released the two new versions 0.8.6 and 0.9.0, you would see the following if you ran cargo update:

$ cargo update
    Updating crates.io index
    Updating rand v0.8.5 -> v0.8.6

Cargo ignores the 0.9.0 release. At this point, you would also notice a change in your Cargo.lock file noting that the version of the rand crate you are now using is 0.8.6. To use rand version 0.9.0 or any version in the 0.9.x series, you’d have to update the Cargo.toml file to look like this instead:

[dependencies]
rand = "0.9.0"
1 Like

I agree the sentence is weird. Perhaps there is any edit history (either in the repo or in archived versions of the website)[1] that show previous versions of that paragraph where the sentence in question did still have context in which it made sense to start with “Otherwise, by default …” :thinking:


  1. I might check for that myself ↩︎

1 Like