Conditional compilation selects Rust source items according to compile-time configuration. Cargo features can make macros, imports, modules, and generated code optional, so users compile only the capabilities they enable. section 10.3
Apply the technique by connecting a Cargo feature to cfg attributes:
- Enable the feature in the dependency declaration; otherwise, the guarded macro is unknown while an unguarded macro continues working. section 10.3
Feature-gated attribute macro
A library can gate `config_struct` and its `struct_output` module behind `struct`. Consumers enable it with `features = ["struct"]`, then use `#[config_struct]` on `ConfigStruct`.




