MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / split_name_attrs

Function split_name_attrs

atomic-canonical/src/directive.rs:297–310  ·  view source on GitHub ↗

Split "name{attrs}" (or "name") into (name, attrs-source-without-braces).

(s: &str)

Source from the content-addressed store, hash-verified

295
296/// Split "name{attrs}" (or "name") into (name, attrs-source-without-braces).
297fn split_name_attrs(s: &str) -> (String, &str) {
298 let s = s.trim();
299 if let Some(open) = s.find('{') {
300 let name = s[..open].trim().to_string();
301 let attrs = if let Some(close) = s.rfind('}') {
302 &s[open + 1..close]
303 } else {
304 &s[open + 1..]
305 };
306 (name, attrs)
307 } else {
308 (s.to_string(), "")
309 }
310}
311
312/// Parse `#id key=value key2="quoted value"` into (id, attrs).
313fn parse_attrs(src: &str) -> Result<(Option<String>, BTreeMap<String, String>)> {

Callers 2

parseFunction · 0.85
parse_leafFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected