Conditional compilation based on whether this is a root crate or a dependency.
dbg!() and other debugging things may want to only activate when the crate is being actively developed, not used as a dependency.
Cargo knows if this is a root crate or a dependencly and can specify a
--cfg to rustc. Rustc makes it available to the code just like with
cfg(feature = ...).
- Shall it be not just a crate root, but also all crates in root workspace? When compiling an example, shall the main crate be also like a crate root?
- Are there other use cases, not for debugging?
- Mix with features (
--cfg feature=crate_root) or something stand-alone (
- Code that relies on this feature may suddenly break only when used as a dependency, compilcating debugging;