Skip to main content

filter_newlines

Function filter_newlines 

Source
pub fn filter_newlines(tokens: Vec<Token>) -> Vec<Token>
Expand description

Drop the line breaks that don’t end a statement.

A line break is kept only where a statement could end. It is dropped:

  • inside ( ) and [ ] (but not inside a { } block nested in them);
  • after a token that can’t end an expression, such as a binary operator, ,, => or an opening bracket;
  • before a line starting with . (method chains);
  • when it repeats a previous line break, or starts the file.