Split by commas at the top level of parentheses nesting. "(...), (...)" → ["(...)", "(...)"]
(s: &str)
| 219 | /// Split by commas at the top level of parentheses nesting. |
| 220 | /// "(...), (...)" → ["(...)", "(...)"] |
| 221 | fn split_top_level_parens(s: &str) -> Option<Vec<String>> { |
| 222 | let mut parts = Vec::new(); |
| 223 | let mut depth = 0; |
| 224 | let mut start = 0; |
| 225 | |
| 226 | for (i, ch) in s.char_indices() { |
| 227 | match ch { |
| 228 | '(' => depth += 1, |
| 229 | ')' => depth -= 1, |
| 230 | ',' if depth == 0 => { |
| 231 | parts.push(s[start..i].to_string()); |
| 232 | start = i + 1; |
| 233 | } |
| 234 | _ => {} |
| 235 | } |
| 236 | } |
| 237 | if start < s.len() { |
| 238 | parts.push(s[start..].to_string()); |
| 239 | } |
| 240 | if parts.is_empty() { None } else { Some(parts) } |
| 241 | } |
| 242 | |
| 243 | /// Split geometry collection items by top-level commas, handling nested parens. |
| 244 | fn split_top_level_items(s: &str) -> Vec<String> { |
no test coverage detected