MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / unquote

Function unquote

compiler/src/modules/packages/mod.rs:152–160  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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. */
152fn 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). */
163fn read_spec(src: &str, tokens: &[Token], j: usize) -> Option<(ImportSpec, usize)> {

Callers 1

read_specFunction · 0.85

Calls 1

iterMethod · 0.45

Tested by

no test coverage detected