pub fn apply_fields<'a>(
text: &str,
fields: impl IntoIterator<Item = &'a Field>,
f: impl Fn(&Field, &str) -> Option<String>,
) -> Result<String, RenderError>Expand description
Rewrite the spans of one text, returning the result.
f receives each field and the text it covers, and returns the replacement
or None to leave it alone. Every field must index text — filter by
Field::at before calling, since a range from another location means
nothing here.
Nested spans are how the parser reports an address inside a channel name, so
a replacement contained in another replacement is dropped: the outer rewrite
already covers those bytes. Two replacements that overlap only partially have
no such reading and are RenderError::OverlappingSpans.
Bounds and character boundaries are checked for every field, so this never panics on a hand-built span.