| 244 | } |
| 245 | |
| 246 | function extractRust(content) { |
| 247 | const exports = []; |
| 248 | const imports = []; |
| 249 | const symbols = []; |
| 250 | let m; |
| 251 | |
| 252 | const pubRe = /\bpub\s+(?:async\s+)?(?:fn|struct|enum|trait|type|const|static)\s+(\w+)/g; |
| 253 | while ((m = pubRe.exec(content)) !== null) { |
| 254 | exports.push(m[1]); |
| 255 | symbols.push(m[1]); |
| 256 | } |
| 257 | |
| 258 | const useRe = /^\s*use\s+([\w:]+)/gm; |
| 259 | while ((m = useRe.exec(content)) !== null) imports.push(m[1]); |
| 260 | |
| 261 | return { exports: dedupe(exports), imports: dedupe(imports), symbols: dedupe(symbols) }; |
| 262 | } |
| 263 | |
| 264 | function dedupe(values) { |
| 265 | return Array.from(new Set(values.filter(Boolean))); |