Skip to main content

scan_template

Function scan_template 

Source
pub fn scan_template(interior: &str) -> Result<Vec<TemplatePart>, ScanError>
Expand description

Re-scan the interior of a backtick template into template parts.

interior is the text between the backticks (the caller strips them). The returned parts alternate between literal runs and captures; consecutive literal characters are coalesced into one Literal part with the whitespace policy of the run. Spans are relative to interior; the HIR bridge rebases them onto the file by the template token’s start + 1.

§Errors

Returns ScanError on a malformed template: a bad escape, an unterminated or empty capture, a capture name that is not an identifier, or a capture body that is not a parser expression.