Skip to main content

Macros

Struct Macros 

Source
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

Source

pub fn from_element(el: &Element) -> Self

Source

pub fn from_pairs<K: Into<String>, V: Into<String>>( pairs: impl IntoIterator<Item = (K, V)>, ) -> Self

Source

pub fn get(&self, name: &str) -> Option<&str>

Source

pub fn is_empty(&self) -> bool

Source

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.

Source

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.

Source

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.

Source

pub fn over(defaults: &Macros, over: &Macros, left: &AtomicUsize) -> Macros

defaults with over on top of them, sharing both: over is the macros an embedding passes to the display it embeds, and is a whole chain of the embedder’s layers, which are not copied.

Source

pub fn own_bytes(&self) -> usize

The bytes of the definitions in this layer alone.

Trait Implementations§

Source§

impl Clone for Macros

Source§

fn clone(&self) -> Macros

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Macros

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Macros

Source§

fn default() -> Macros

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Macros

Source§

fn eq(&self, other: &Macros) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Macros

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.