/// Tries to fix the delimiter stack given the closing delimiter `delim`.
/// Returns if the closing delimiter should be emitted or not.
///
/// The primary idea is that, when the closing delimiter matches some internal
/// element of the stack, the user probably forgot/deleted internal delimiters
/// of an expression. In this case, we emit extra tokens that will set the stack
/// to a state that, at least, the parsing can continue without problems.
///
/// When the closing delimiter doesn't match any internal element of the sack, we
/// simply doesn't emit it, as this is probably an extra character that the user
/// miss-typed or forgot to remove, and hope that further in the source input
/// the stack will be fixed.
Tries to fix the delimiter stack given the closing delimiter `delim`.
Returns if the closing delimiter should be emitted or not.

The primary idea is that, when the closing delimiter matches some internal
element of the stack, the user probably forgot/deleted internal delimiters
of an expression. In this case, we emit extra tokens that will set the stack
to a state that, at least, the parsing can continue without problems.

When the closing delimiter doesn't match any internal element of the sack, we
simply doesn't emit it, as this is probably an extra character that the user
miss-typed or forgot to remove, and hope that further in the source input
the stack will be fixed.
Tries to fix the delimiter stack given the closing delimiter ` delim ` . Returns if the closing delimiter should be emitted or not . The primary idea is that when the closing delimiter matches some internal element of the stack the user probably forgot / deleted internal delimiters of an expression . In this case we emit extra tokens that will set the stack to a state that at least the parsing can continue without problems . When the closing delimiter doesn ' t match any internal element of the sack we simply doesn ' t emit it as this is probably an extra character that the user miss - typed or forgot to remove and hope that further in the source input the stack will be fixed .
fn try_fix_delimiter_stack(&mut self, delim: Delimiter, start: Location) -> bool {
        let delim_until_match = self
            .open_braces
            .iter()
            .rev()
            .take_while(|b| !delim.closes(**b))
            .count();
        if delim_until_match == self.open_braces.len() {
            // We didn't find a match in the stack, don't emit the delimiter.
            false
        } else {
            // We found a match in the stack, rollback the stack to before it,
            // emitting the correct delimiters.
            for _ in 0..delim_until_match {
                self.emit_opposed_delimiter(start);
            }
            true
        }
    }
fn try_fix_delimiter_stack ( & mut self , delim : Delimiter , start : Location ) -> bool { let delim_until_match = self . open_braces . iter ( ) . rev ( ) . take_while ( | b | ! delim . closes ( * * b ) ) . count ( ) ; if delim_until_match == self . open_braces . len ( ) { // We didn't find a match in the stack, don't emit the delimiter. false } else { // We found a match in the stack, rollback the stack to before it, // emitting the correct delimiters. for _ in 0 .. delim_until_match { self . emit_opposed_delimiter ( start ) ; } true } }
Tries to fix the delimiter stack given the closing delimiter `delim`.
Tries to fix the delimiter stack given the closing delimiter ` delim ` .
&mut self
delim
Delimiter
start
Location