From d002cdf451e1c6efbf7cd7f2303264526b6f8a92 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 12 Aug 2021 16:00:09 +0200 Subject: Named arguments for user defined functions --- src/syntax/expr.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/syntax/expr.rs') diff --git a/src/syntax/expr.rs b/src/syntax/expr.rs index cf9aff4a..9292d5b6 100644 --- a/src/syntax/expr.rs +++ b/src/syntax/expr.rs @@ -437,11 +437,20 @@ pub struct ClosureExpr { /// This only exists if you use the function syntax sugar: `let f(x) = y`. pub name: Option, /// The parameter bindings. - pub params: Rc>, + pub params: Vec, /// The body of the closure. pub body: Rc, } +/// An parameter to a closure: `x` or `draw: false`. +#[derive(Debug, Clone, PartialEq)] +pub enum ClosureParam { + /// A positional parameter. + Pos(Ident), + /// A named parameter with a default value. + Named(Named), +} + /// A with expression: `f with (x, y: 1)`. /// /// Applies arguments to a function. -- cgit v1.2.3