Skip backwards past a balanced bracket group `[…]` in a char slice. `pos` must point one past the closing `]`. Returns the index of the opening `[`, or `None` if brackets are unbalanced.
(chars: &[char], pos: usize)
| 74 | /// `pos` must point one past the closing `]`. Returns the index of the |
| 75 | /// opening `[`, or `None` if brackets are unbalanced. |
| 76 | fn skip_balanced_brackets_back(chars: &[char], pos: usize) -> Option<usize> { |
| 77 | if pos == 0 || chars[pos - 1] != ']' { |
| 78 | return None; |
| 79 | } |
| 80 | let mut depth: u32 = 0; |
| 81 | let mut j = pos; |
| 82 | while j > 0 { |
| 83 | j -= 1; |
| 84 | match chars[j] { |
| 85 | ']' => depth += 1, |
| 86 | '[' => { |
| 87 | depth -= 1; |
| 88 | if depth == 0 { |
| 89 | return Some(j); |
| 90 | } |
| 91 | } |
| 92 | _ => {} |
| 93 | } |
| 94 | } |
| 95 | None |
| 96 | } |
| 97 | |
| 98 | /// Check if the `new` keyword (followed by whitespace) appears immediately |
| 99 | /// before the identifier starting at position `ident_start`. |
no outgoing calls
no test coverage detected