Cargo commands, crates, modules and visibility, workspaces, testing, macros and unsafe Rust.
36 cards · basic cards · AI-written, checked twice. Edit anything.
- What Cargo command creates a new binary project with a main.rs file?
Show answer
cargo new <project-name>
- What does `cargo build` do?
Show answer
Compiles the project and creates a binary executable in target/debug
- What is the difference between `cargo build` and `cargo check`?
Show answer
cargo check verifies code compiles without producing a binary, faster than cargo build
- What does `cargo run` do?
Show answer
Compiles and immediately executes the binary in one command
- What does `cargo test` compile and execute?
Show answer
All test functions marked with #[test] attribute
- What does `cargo doc` generate?
Show answer
HTML documentation from doc comments in the source code
- What is the purpose of Cargo.toml?
Show answer
Define project metadata, dependencies, and build configuration
- What Cargo.toml section contains the project name, version, and edition?
Show answer
[package]
- What is a library crate?
Show answer
A crate that provides reusable code, has no main function, root is src/lib.rs
- What is a binary crate?
Show answer
A crate compiled to an executable program with a main function as root is src/main.rs
- What is the default crate root file for a library?
Show answer
src/lib.rs
- What is the default crate root file for a binary?
Show answer
src/main.rs
- In Rust 2018 edition and later, is `extern crate` needed?
Show answer
No, external crates are brought into scope automatically via use statements
- What does the `pub` keyword do?
Show answer
Makes an item public, accessible from outside its defining module
- What does `pub(crate)` visibility restrict access to?
Show answer
Items only accessible within the current crate, not from external crates