Rust Programming By Example
上QQ阅读APP看书,第一时间看更新

Back to our Cargo.toml file

To go back to our Cargo.toml file, it's also possible to use crates directly from their repositories; you just have to specify this when adding the dependency in your Cargo.toml file. Generally, the published version is less advanced than the one on the corresponding repository but will be more stable.

So for example, if we want to use the repository version for the sdl2 crate, we need to write in our Cargo.toml file:

[dependencies]
sdl2 = { git = "https://github.com/Rust-SDL2/rust-sdl2" }

Easy right? Cargo can also start tests or benchmarks, install binaries, handle special builds through a build file (by default in build.rs), or handle features (we'll come back to this point later in this part).

To put it simply, it's a complete tool, and explaining most of its features would take a lot of time and space, so we'll just stick to the basics for the moment.

You can find a very good documentation/tutorial on Cargo at http://doc.crates.io/index.html.