liveBook · Manning

Additive feature

As explained in Write Powerful Rust Macros

An additive feature is a crate feature that only adds functionality and does not disable functionality already available.

An additive feature is a Cargo feature that adds functionality without disabling anything already available. Cargo depends on this behavior when resolving crate dependencies. section 10.3

Feature-gated macro functionality

A macro crate can define independent features such as `struct` and `functional`, with `functional` enabled by default. The `struct` feature adds a configuration-struct macro and its implementation; it does not remove existing functionality.

Apply the rule when designing crate features:

  • Do not use a feature to exclude an implementation that the default configuration already provides. section 10.3

How Write Powerful Rust Macros covers it

How deep it goes
Defines additivity and demonstrates feature-gated macro code, without detailing Cargo’s full resolution algorithm.
Examples
Uses `struct` and `functional` features to add macros, generated conversions, and configuration-struct functionality.
What you can do after
Apply the additive-feature rule when configuring Cargo features for a macro crate.
How it connects
Connects crate features with Cargo, dependency resolution, conditional compilation, and procedural macros.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Write Powerful Rust Macros. The section links point to the parts of the book it draws on.