(input: syn::parse::ParseStream)
| 15 | |
| 16 | impl 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 | } |
nothing calls this directly
no test coverage detected