Rustlers Atom 0.3 - Cargo
April 18, 2026•298 words
Cargo is Rust’s project+build+package manager in one. You describe your app or library in Cargo.toml, put code under src/, and let Cargo handle compilation, tests, docs, and dependencies reproducibly.
Build & Run
Make a new binary crate (has a main):
cargo new hello cd hello`
Make a library instead:
cargo new mylib --lib
If you’re turning an existing folder into a project, use:
shell
cargo init
Build once to prime the target dir with:
shell
cargo build
This produces a debug build (fast to compile, slower to run). For optimized binaries:
cargo build --release
Artifacts land in target/debug/ or target/release/. Use cargo clean to wipe builds if you need a fresh compile.
You can run your binary directly with cargo for semplicity. Pass args after --:
cargo run
cargo run -- --port 8080
When you’re iterating, you can choose to compile without producing binaries. The command below catches errors quickly and keeps your edit-compile loop snappy.
cargo check
Test (unit, integration, selection)
Run all tests:
cargo test
Run only tests matching a filter:
cargo test parser_handles_utf8
Integration tests live in tests/; unit tests usually sit next to code under src/.
Dependencies
All depentency are managed by the Cargo.toml but you can manage it without editing by hand with this commands:
cargo add anyhow
cargo add serde --features derive
cargo update
cargo tree
Lints, format and docs
Keep formatting and lints consistent with:
cargo fmt cargo clippy
Build and open your documentation (including your crate’s docs):
cargo doc --open