Find the position of the matching `)` for the first `(`, handling nesting. The input `s` is expected to start *after* the opening `(`. Returns the byte offset of the closing `)` within `s`.
(s: &str)
| 31 | /// The input `s` is expected to start *after* the opening `(`. Returns |
| 32 | /// the byte offset of the closing `)` within `s`. |
| 33 | pub(super) fn find_matching_paren(s: &str) -> Option<usize> { |
| 34 | let mut depth = 0i32; |
| 35 | for (i, c) in s.char_indices() { |
| 36 | match c { |
| 37 | '(' => depth += 1, |
| 38 | ')' => { |
| 39 | if depth == 0 { |
| 40 | return Some(i); |
| 41 | } |
| 42 | depth -= 1; |
| 43 | } |
| 44 | _ => {} |
| 45 | } |
| 46 | } |
| 47 | None |
| 48 | } |
| 49 | |
| 50 | /// Split a parameter string on commas, respecting nested `()`, `<>`, |
| 51 | /// `[]`, and `{}` delimiters. |
no outgoing calls
no test coverage detected