MCPcopy Index your code
hub / github.com/carllerche/assert-struct / parse

Method parse

assert-struct-macros/src/pattern/closure.rs:17–34  ·  view source on GitHub ↗
(input: syn::parse::ParseStream)

Source from the content-addressed store, hash-verified

15
16impl Parse for PatternClosure {
17 fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
18 // Closure pattern: |x| expr or move |x| expr for custom validation (escape hatch)
19 // Examples: `|x| x > 5`, `move |x| complex_logic(x)`, `|x| { x.len() > 0 }`
20 let closure: syn::ExprClosure = input.parse()?;
21
22 // Validate: exactly one parameter
23 if closure.inputs.len() != 1 {
24 return Err(syn::Error::new_spanned(
25 &closure.inputs,
26 "Closure must have exactly one parameter",
27 ));
28 }
29
30 Ok(PatternClosure {
31 node_id: next_node_id(),
32 closure,
33 })
34 }
35}

Callers

nothing calls this directly

Calls 2

next_node_idFunction · 0.85
lenMethod · 0.80

Tested by

no test coverage detected