(text: string, sep: string)
| 717 | |
| 718 | /** `text` parted at its top-level `sep`s, outside `()`, `[]`, `{}` and `<>` (`->` closes nothing). */ |
| 719 | export function splitRustTopLevel(text: string, sep: string): string[] { |
| 720 | const parts: string[] = []; |
| 721 | let depth = 0; |
| 722 | let start = 0; |
| 723 | for (let i = 0; i < text.length; i++) { |
| 724 | const c = text[i]!; |
| 725 | if (c === '(' || c === '[' || c === '{' || c === '<') depth++; |
| 726 | else if (c === ')' || c === ']' || c === '}' || (c === '>' && text[i - 1] !== '-' && text[i - 1] !== '=')) depth--; |
| 727 | else if (c === sep && depth === 0) { |
| 728 | parts.push(text.slice(start, i)); |
| 729 | start = i + 1; |
| 730 | } |
| 731 | } |
| 732 | parts.push(text.slice(start)); |
| 733 | return parts.map((p) => p.trim()).filter((p) => p !== ''); |
| 734 | } |
| 735 | |
| 736 | /** |
| 737 | * The bounds a generic parameter `name` is declared with, read from the |
no test coverage detected