(text: string, sep: string)
| 828 | |
| 829 | /** `text` parted at its top-level `sep`s, outside `()`, `[]`, `{}` and `<>` (`->` closes nothing). */ |
| 830 | export function splitRustTopLevel(text: string, sep: string): string[] { |
| 831 | const parts: string[] = []; |
| 832 | let depth = 0; |
| 833 | let start = 0; |
| 834 | for (let i = 0; i < text.length; i++) { |
| 835 | const c = text[i]!; |
| 836 | if (c === '(' || c === '[' || c === '{' || c === '<') depth++; |
| 837 | else if (c === ')' || c === ']' || c === '}' || (c === '>' && text[i - 1] !== '-' && text[i - 1] !== '=')) depth--; |
| 838 | else if (c === sep && depth === 0) { |
| 839 | parts.push(text.slice(start, i)); |
| 840 | start = i + 1; |
| 841 | } |
| 842 | } |
| 843 | parts.push(text.slice(start)); |
| 844 | return parts.map((p) => p.trim()).filter((p) => p !== ''); |
| 845 | } |
| 846 | |
| 847 | /** |
| 848 | * The bounds a generic parameter `name` is declared with, read from the |
no test coverage detected