Content between the first quote and its matching close; tolerates string prefixes (r, b, f). Specs carry no escapes, so a raw slice suffices. */
(raw: &str)
| 150 | |
| 151 | /* Content between the first quote and its matching close; tolerates string prefixes (r, b, f). Specs carry no escapes, so a raw slice suffices. */ |
| 152 | fn unquote(raw: &str) -> String { |
| 153 | let bytes = raw.as_bytes(); |
| 154 | let Some(open) = bytes.iter().position(|&c| c == b'"' || c == b'\'') else { return raw.to_string() }; |
| 155 | let quote = bytes[open] as char; |
| 156 | match raw[open + 1..].rfind(quote) { |
| 157 | Some(rel) => raw[open + 1..open + 1 + rel].to_string(), |
| 158 | None => raw.to_string(), |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | /* Reads the module spec at token `j`: a quoted string or a dotted bare name. Returns (spec, index past it). */ |
| 163 | fn read_spec(src: &str, tokens: &[Token], j: usize) -> Option<(ImportSpec, usize)> { |