Skip to main content

parentheses_iterator

Function parentheses_iterator 

Source
pub fn parentheses_iterator<'a>(
    expr: ExprRef<'a>,
    parent: Option<AnyNodeRef<'_>>,
    tokens: &'a Tokens,
) -> impl Iterator<Item = TextRange> + 'a
Expand description

Returns an iterator over the ranges of the optional parentheses surrounding an expression.

E.g. for ((f())) with f() as expression, the iterator returns the ranges (1, 6) and (0, 7).

Note that without a parent the range can be inaccurate, e.g. f(a) we falsely return a set of parentheses around a even if the parentheses actually belong to f. That is why you should generally prefer parenthesized_range.