Function rsconf::declare_cfg
source · pub fn declare_cfg(name: &str, enabled: bool)
Expand description
Informs the compiler of a cfg
with the name name
, enabled if enabled
is set to true
.
Enables conditional compilation of code behind #[cfg(name)]
or with if cfg!(name)
(without quotes around name
).
As of rust 1.80, using #[attr(cfg = "foo")]
when said feature is not enabled results in a
compile-time warning as rust tries to protect against inadvertent use of invalid/unknown
features. Unlike enable_cfg()
, this function informs rustc
about the presence of a feature
called name
even when it’s not enabled, so that #[attr(not(cfg = "foo"))]
does not cause
cause warnings when the foo
cfg is not enabled.
See also: declare_cfg_values()
.