#[cfg_attrs { ... }]
Provides an alternative syntax to #[cfg_attr(...)] that is easier to use with doc
comments.
Syntax
CfgAttrsAttribute :
cfg_attrsAttribute :
ConfigureAttribute | OuterAttributeConfigureAttribute :
#[configure(ConfigureMeta)]ConfigureMeta :
ConfigurationPredicate,AttributesAttributes :
Attribute* (,Attribute* )*,?
Usage
Placing #[cfg_attrs] on an item enables a #[configure(<condition>, <attributes>)] helper
attribute to be used on that item.
The syntax of that #[configure(...)] attribute is much like #[cfg_attr(...)], except
the configured attributes use full attribute syntax. The advantage of this is that doc comments,
which expand to #[doc = "..."] attributes, can be used in the #[configure(...)] syntax.
Examples
/// This is an example struct.
This will expand to the following usage of #[cfg_attr(...)]:
/// This is an example enum.
Which, if debug assertions are active, would be expanded to:
/// This is an example enum.
///
/// Hello! These are docs that only appear when
/// debug assertions are active.
Or, if the magic feature is enabled:
/// This is an example enum.
#[cfg_attrs(...)] may also be used with attributes other than doc comments, though there is
no real benefit to doing this:
With that example expanding to:
And expanding, if the magic feature is enabled, to: