Crates, workspaces and build
Every lesson so far was built with cargo build, and this chapter opens the command. These ten lessons look at what the three cargo commands do and where the target folder goes, then at Cargo.toml: the metadata, a dependency from crates.io, the version requirement and the lock file. Features, a workspace of several crates and a build.rs follow, then the profiles that set the optimisation, the library target with its documentation tests, a cdylib that a C program links, the editions from 2015 to 2024, and the old Rust that still compiles on this toolchain.
079
cargo build, run and check
the three commands, the target folder, incremental builds and a build that fails (C++ 097)
Open
080
Cargo.toml and dependencies
package metadata, a dependency from crates.io, a version requirement and Cargo.lock (C++ 099, 101, 103)
Open
081
Cargo features
a feature in Cargo.toml, cfg(feature), an optional dependency and a build with --features (no C++ counterpart)
Open
082
Workspaces and multiple crates
a workspace root, a library and a binary member, path dependencies and one lock file (C++ 098, 100)
Open
083
build.rs
a build script, cargo:rerun-if-changed, a generated constant and generated code (C++ 098)
Open
084
Debug, release and profiles
debug against release, opt-level, overflow checks, debug assertions and a profile per need (C++ 102)
Open
085
Library crates and targets
src/lib.rs, lib and bin targets in one package, doc tests and a library used by a binary (C++ 100)
Open
086
cdylib and staticlib crates
crate-type, a .so built by cargo, a static library and a C program that links it (C++ 104)
Open
087
Editions and modern Rust
edition 2015 to 2024, what an edition may change, the 2024 match ergonomics and a crate that moves (C++ 132, 133, 134)
Open
088
Reading old Rust
try!, bare trait objects, extern crate, and an old module modernised step by step (C++ 135)
Open