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

Method parse

assert-struct-macros/src/pattern/enum_pattern.rs:31–49  ·  view source on GitHub ↗

Parses an enum pattern with a required path prefix. # Example Input ```text Some(> 30) Event::Click(>= 0, < 100) Ok(== 42) Status::Active // Unit variant (no parens) ``` This assumes the input starts with a path, optionally followed by parenthesized content.

(input: ParseStream)

Source from the content-addressed store, hash-verified

29 ///
30 /// This assumes the input starts with a path, optionally followed by parenthesized content.
31 fn parse(input: ParseStream) -> syn::Result<Self> {
32 let path: syn::Path = input.parse()?;
33
34 // Check if there are parentheses (tuple variant) or not (unit variant)
35 let elements = if input.peek(syn::token::Paren) {
36 let content;
37 syn::parenthesized!(content in input);
38 TupleElement::parse_comma_separated(&content)?
39 } else {
40 // Unit variant - no elements
41 vec![]
42 };
43
44 Ok(PatternEnum {
45 node_id: next_node_id(),
46 path,
47 elements,
48 })
49 }
50}

Callers

nothing calls this directly

Calls 1

next_node_idFunction · 0.85

Tested by

no test coverage detected