Skip to main content

render_from_ast

Function render_from_ast 

Source
pub fn render_from_ast(
    source: &str,
    module: &Module,
    trivia: &[Trivia],
) -> Result<String, String>
Expand description

Reconstruct source from the AST’s byte spans plus the lexer’s trivia.

The AST-level mirror of lexer::render_lossless: it checks the spans nest (V2), then tiles the file from every content node span merged with the non-blank trivia spans (V1/V3). Ok(reconstruction) is byte-identical to source; Err names the first nesting violation or the first run of bytes no span covers (content the AST dropped).

Obtain trivia from crate::lexer::lex_with_trivia.