pub enum SubstitutionSpec {
Source(Vec<String>),
Explicit(Vec<Substitution>),
Modifiers(Vec<SubstitutionOp>),
}Expand description
Specification for substitutions to apply to a block.
Parsed documents use Self::Source to preserve the entries in the subs
attribute, including groups, aliases, duplicates and modifiers. Only whitespace
around each entry is trimmed. Attribute references in the list have already
been expanded by metadata parsing.
Standalone none and empty values use Self::Explicit with an empty list.
They disable substitutions, whereas absent metadata uses block defaults.
Mixed lists retain none because its position can select the starting list.
Self::resolve derives the effective stages without changing the stored
entries. A plain first entry starts an empty list; a modifier first entry
starts with the supplied block defaults. Later entries operate on that list.
Self::Explicit and Self::Modifiers also support typed construction.
§Serialization
Serializes to a flat array. Source entries retain their spelling, for example
["verbatim", "-macros"]; typed entries use canonical names such as
"special_chars".
Only available when the pre-spec-subs feature is enabled.
Variants§
Source(Vec<String>)
Authored entries, interpreted when resolving against block defaults.
Explicit(Vec<Substitution>)
Explicit list of substitutions to apply (replaces all defaults)
Modifiers(Vec<SubstitutionOp>)
Modifier operations to apply to block-type defaults
Implementations§
Source§impl SubstitutionSpec
impl SubstitutionSpec
Sourcepub fn apply_modifiers(
ops: &[SubstitutionOp],
default: &[Substitution],
) -> Vec<Substitution>
pub fn apply_modifiers( ops: &[SubstitutionOp], default: &[Substitution], ) -> Vec<Substitution>
Apply modifier operations to a default substitution list.
This is used by converters to resolve modifiers with the appropriate baseline.
Sourcepub fn resolve(&self, default: &[Substitution]) -> Vec<Substitution>
pub fn resolve(&self, default: &[Substitution]) -> Vec<Substitution>
Resolve the substitution spec to a concrete list of substitutions.
- For
Source, applies its entries in order, expanding named groups - For
Explicit, returns the list directly - For
Modifiers, applies the operations to the provided default
Trait Implementations§
Source§impl Clone for SubstitutionSpec
impl Clone for SubstitutionSpec
Source§impl Debug for SubstitutionSpec
impl Debug for SubstitutionSpec
impl Eq for SubstitutionSpec
Source§impl Hash for SubstitutionSpec
impl Hash for SubstitutionSpec
Source§impl PartialEq for SubstitutionSpec
impl PartialEq for SubstitutionSpec
Source§impl Serialize for SubstitutionSpec
Available on crate feature pre-spec-subs only.
impl Serialize for SubstitutionSpec
pre-spec-subs only.