Function parse_closure

Source
pub fn parse_closure(input: &str) -> IResult<&str, Closure>
Expand description

Parses a closure expression from the input string.

This is the main entry point for parsing closures. It attempts to parse both single-parameter and two-parameter closures, falling back to parse_closure_conditional if neither form matches.

§Arguments

  • input - The input string to parse

§Returns

Returns IResult<&str, Closure> containing the remaining unparsed input and the parsed closure.

§Examples

let result = parse_closure("x => x * 2");
assert!(result.is_ok());
 
let result = parse_closure("(a, b) => a + b");
assert!(result.is_ok());
 
let result = parse_closure("simple_expression");
assert!(result.is_ok()); // Falls back to conditional parsing