Skip to main content

substitute_attributes

Function substitute_attributes 

Source
pub fn substitute_attributes<'text, 'value>(
    text: &'text str,
    lookup: impl FnMut(&str) -> Option<&'value DocumentAttributeValue<'value>>,
) -> Cow<'text, str>
Expand description

Expand known attribute references once, leaving unresolved references unchanged.

Names contain one or more ASCII letters, digits, underscores, or hyphens. A backslash before a valid reference is removed and protects that reference from lookup. Only valid, unescaped references call lookup; inserted values are not scanned again. Other text and line endings are preserved.

The result borrows the input when no reference is replaced or escape removed.