0Pricing
Learn Rust Coding · Lesson

Features and Profiles

Conditional compilation.

What Are Features?

Features let you enable or disable optional parts of a crate at compile time. They make crates flexible: callers pay only for what they use.

Declaring Features

Define features in the [features] table. Each feature can turn on other features or optional dependencies.

[features]
default = ["json"]
json = []
fast_math = []

All lessons in this course

  1. Cargo Basics
  2. Cargo.toml
  3. Workspaces
  4. Features and Profiles
← Back to Learn Rust Coding