Cargo.toml
specifies dependencies and their versioncargo build
will build your project
Default profile is dev
(debug)
To compile with Release optimizations use --release
flag
Output binaries will be in target/<profile>/
Profiles can be modified in Cargo.toml:
[profile.dev]
opt-level = 0
[profile.release]
opt-level = 3
opt-level
setting controls the number of optimizations Rust will apply to your code, with a range of 0 to 3.cargo run
will build and run your projectcargo check
checks if the project compiles but it does not generate any executable$ cargo build --verbose
. And it will print out each rustc invocation.cargo +<toolchainName>
--features
///
, instead of two and support Markdown notation for formatting the text.cargo doc
rustdoc
tool distributed with Rust and puts the generated HTML documentation in the target/doc directory.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.Result
, describing the kinds of errors that might occur and what conditions might cause those errors to be returned can be helpful to callers so they can write code to handle the different kinds of errors in different ways.unsafe
to call (we discuss unsafety in Chapter 19), there should be a section explaining why the function is unsafe and covering the invariants that the function expects callers to uphold.cargo test
will run the code examples in your documentation as tests!//!
, adds documentation to the item that contains the comments rather than adding documentation to the items following the comments.