liveBook · Manning

Cargo build

As explained in Learn Rust in a Month of Lunches

cargo build is a Cargo command that compiles a Rust program into an executable artifact.

cargo build compiles a Rust program ahead of time. Run it after adding an external crate so Cargo can compile the code while you work; later builds reuse unchanged results through incremental compilation. section 18.1.2

A faster follow-up build

After changing a program that uses an external crate, run cargo build. Cargo avoids recompiling unchanged crates, so the next cargo build or cargo run usually finishes much faster. section 18.1.2

   Compiling random_test v0.1.0 (C:\rust\random_test)
    Finished dev [unoptimized + debuginfo] target(s) in 0.55s
     Running `target\debug\random_test.exe`
f h i d e d 

Use the compilation output to recognize a completed build and see the shorter incremental-build time. section 18.1.2

How Learn Rust in a Month of Lunches covers it

How deep it goes
Explains ahead-of-time and incremental compilation, but defers detailed build configuration.
Examples
Shows repeated builds, external crates, compiler timing output, and generic functions compiled for concrete types.
What you can do after
Operate/configure Cargo to compile code incrementally while developing a Rust program.
How it connects
Links incremental compilation with external crates, cargo run, compile time, and monomorphization.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Rust in a Month of Lunches. The section links point to the parts of the book it draws on.