diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-08-12 16:00:09 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-12 16:07:42 +0200 |
| commit | d002cdf451e1c6efbf7cd7f2303264526b6f8a92 (patch) | |
| tree | 31b8446728a93550cab57d50bba92eb32f280678 /src/syntax/expr.rs | |
| parent | ccb4be4da4e8aeda115b22f2a0b586a86f5e31bd (diff) | |
Named arguments for user defined functions
Diffstat (limited to 'src/syntax/expr.rs')
| -rw-r--r-- | src/syntax/expr.rs | 11 |
1 files changed, 10 insertions, 1 deletions
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<Ident>, /// The parameter bindings. - pub params: Rc<Vec<Ident>>, + pub params: Vec<ClosureParam>, /// The body of the closure. pub body: Rc<Expr>, } +/// 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. |
