cargo

Cargo build cache

Reuse compatible intermediate build work by keeping the same target directory and inputs. Changed source, compiler, profile or flags can invalidate cached work. Never infer a speedup without measurements. Example format: shell. Run only in a disposable copy of the quality-demo fixture with preinstalled matching tools. Expected result (not executed): Both builds should succeed; the second may reuse work. No timing is predicted. Common mistake: Assuming a cache hit guarantees an identical or trustworthy binary.

Formal Syntax & Structure

rust syntaxrust
cargo build --target-dir DIRECTORY

Working Example

Example Snippetrust
cargo build --offline --target-dir lab-targetcargo build --offline --target-dir lab-target
Rust Reference