pub struct Macros(/* private fields */);Expand description
An ordered set of macro definitions. Later definitions win.
A set layered over another (see Macros::with) shares it rather than
copying it, so each widget of a large display costs only its own macros.
Implementations§
Source§impl Macros
impl Macros
pub fn from_element(el: &Element) -> Self
pub fn from_pairs<K: Into<String>, V: Into<String>>( pairs: impl IntoIterator<Item = (K, V)>, ) -> Self
pub fn get(&self, name: &str) -> Option<&str>
pub fn is_empty(&self) -> bool
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
Every definition, in the order Macros::get lets later ones win:
a layer’s base first, then its parent (and all below it), then
its own.
Sourcepub fn with(&self, inner: &Macros) -> Macros
pub fn with(&self, inner: &Macros) -> Macros
These macros with inner layered on top. Values in inner are first
expanded against self, so <P>$(P):SUB</P> works. Only inner’s
own definitions are used, not the layers under it: for a whole chain,
such as a link’s, use Macros::over.
Sourcepub fn with_budget(&self, inner: &Macros, left: &AtomicUsize) -> Macros
pub fn with_budget(&self, inner: &Macros, left: &AtomicUsize) -> Macros
Macros::with, where expanding the values takes the size of their
text and result from left, which several layers may share. Once it
is spent, values are kept as written, not expanded, so nested
definitions that each double the last, in many widgets, can’t use
memory or time without bound. Only the definitions made in inner
itself are used, at most [MAX_LAYER_MACROS] of them, and no more
than [MAX_LAYERS] deep.