Skip to main content
Module 9 · Lesson 2 of 319/24 in the course~16 min
Module lessons (2/3)

Cargo.toml, Crate, Feature Flags and SemVer

Lesson preview5 hands-on exercises readyCourse Rust · Module 9 — Modules, Cargo and Testing

Anatomy of Cargo.toml and Cargo.lock, release vs dev profile, configuring dependencies (serde) and conditional features.

What you'll learn in this lesson

  • Distinguish the difference between Package, Binary/Library Crate, and the role of Cargo.toml vs Cargo.lock.
  • Handle versions with SemVer, profiles (dev vs --release), and compiler optimizations.
  • Enable conditional code and optional modules via #[cfg(feature = "...")].

Overview

Cargo is Rust's official package manager and build tool: it downloads dependencies from crates.io, compiles the entire crate graph, runs tests, generates documentation (cargo doc), and manages multi-package workspaces.

A typical project has a manifest Cargo.toml that declares optional metadata, dependencies, and feature flags:

Sections covered in this lesson

  1. 11. Anatomy of Cargo.toml and SemVer
  2. 22. Cargo.lock: 100% playable builds
  3. 33. dev vs --release profiles and conditional compilation
  4. 44. Multi-crate workspaces and build profiles
  5. 5Practical exercises
  6. 6Check for understanding
Pro Lesson · Module 9 — Modules, Cargo and Testing

Unlock "Cargo.toml, Crate, Feature Flags and SemVer" and the full Course Rust curriculum

Anatomy of `Cargo.toml` and `Cargo.lock`, release vs dev profile, configuring dependencies (`serde`) and conditional features.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Course Rust plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.