Skip to main content

format_node

Function format_node 

Source
pub fn format_node(node: &SyntaxNode, config: &FormatConfig) -> FormatResult
Expand description

Format the smallest enclosing CST subtree for “Format Selection” (T010).

node is expected to be a value-position node (struct / tuple / list / map / enum-variant / unit / literal) or the document root. For any other node — i.e. no clean subtree boundary — this returns FormatResult::NoOp. The rest of the document is the caller’s responsibility (the caller splices the returned text in place); this function only produces the canonical text for node’s span.