MCPcopy Create free account
hub / github.com/carllerche/assert-struct / parse

Method parse

assert-struct-macros/src/pattern/map.rs:27–45  ·  view source on GitHub ↗

Parses a map pattern: #{ "key": pattern, "key2": pattern, .. } # Example Input ```text #{ "name": "Alice", "age": >= 18 } #{ "key": > 5, .. } ```

(input: syn::parse::ParseStream)

Source from the content-addressed store, hash-verified

25 /// #{ "key": > 5, .. }
26 /// ```
27 fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
28 // Consume the # token
29 let _: Token![#] = input.parse()?;
30
31 // Capture the span of the `{` token before consuming it.
32 let span = input.span();
33 let content;
34 syn::braced!(content in input);
35
36 // Parse the map entries
37 let (entries, rest) = parse_map_entries(&content)?;
38
39 Ok(PatternMap {
40 node_id: next_node_id(),
41 span,
42 entries,
43 rest,
44 })
45 }
46}
47
48/// Parse map entries: comma-separated key-value pairs with optional rest pattern

Callers 1

parse_map_entriesFunction · 0.45

Calls 3

parse_map_entriesFunction · 0.85
next_node_idFunction · 0.85
spanMethod · 0.45

Tested by

no test coverage detected