Skip to main content

body_single_expression

Function body_single_expression 

Source
pub fn body_single_expression(body: Option<Node<'_>>) -> Option<Node<'_>>
Expand description

Get the single expression from a body node, if the body has exactly one expression. For StatementsNode bodies, returns the first (and only) statement. For single-expression bodies (non-StatementsNode), returns the body node itself. Returns None if body is empty or has multiple expressions.