Skip to main content

Module cfg

Module cfg 

Source
Expand description

The attributes that decide whether a handler, or one of its enhancer entries, is compiled, which #[handlers] copies onto every item it writes that names the handler’s generated items, and the reading of a method’s attributes through cfg_attr.

An attribute macro receives the items inside its input with their #[cfg] and #[cfg_attr] unevaluated, so #[handlers] sees a method behind #[cfg(feature = "x")] whether or not the feature is on. Rustc evaluates that cfg after #[handlers] has expanded, and with the feature off it removes the method together with its transport attribute, which then writes none of __ULO_KEY_<name>, __ULO_CHECKS_<name> and __ulo_mount_<name>. Likewise #[cfg_attr(feature = "x", guards(..))] reaches #[handlers] as a cfg_attr, and expands to #[guards(..)] only after #[handlers] has run; take reads through it, so #[handlers] takes the entry with its predicate as a gate.

Structs§

GatedAttr
One attribute as rustc applies it once every cfg_attr around it is evaluated, with the predicates of those cfg_attrs, outermost first. An attribute written outside any cfg_attr has no predicates.

Functions§

gates_of
One #[cfg(<predicate>)] per predicate, spanned at the predicate.
leaves
Every outer attribute among attrs, read through cfg_attr at any depth, in the order written: #[cfg_attr(a, inline, cfg_attr(b, get("/")))] yields inline behind a and get("/") behind a and b. An inner attribute, or a cfg_attr whose arguments do not read as a predicate followed by attributes, is yielded whole, with no predicates.
presence_gates
The attributes among attrs that decide whether the item carrying them is compiled, each as an outer attribute: every cfg as written, and every cfg_attr whose expansion holds a cfg, reduced to the branches that hold one. The reduction keeps an attribute that applies only to a method, such as #[cfg_attr(test, cfg(unix), inline)]’s inline, off the items a copy goes on. Empty for an item compiled in every configuration.
take
Removes from attrs every attribute leaves yields that take accepts, and returns those, in the order written. A cfg_attr left holding nothing is removed; one holding something else keeps it: #[cfg_attr(p, doc = "..", guards(A))] becomes #[cfg_attr(p, doc = "..")].
under
#[cfg_attr(<predicates>, <meta>)], the predicates joined with all(..) when there are several; #[<meta>] when there are none.