summaryrefslogtreecommitdiff
path: root/src/syntax/ast.rs
diff options
context:
space:
mode:
authorMarmare314 <49279081+Marmare314@users.noreply.github.com>2023-04-26 11:32:11 +0200
committerGitHub <noreply@github.com>2023-04-26 11:32:11 +0200
commit59957746e91c1322a8ca6d228bcaa0f31941ee1b (patch)
treed928dea7c99f1d9f17107aac8008b5b7e870d190 /src/syntax/ast.rs
parent6134e3f4ee5298153c36d344df97f36279931c33 (diff)
Pattern as parameter (#854)
Diffstat (limited to 'src/syntax/ast.rs')
-rw-r--r--src/syntax/ast.rs9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs
index 1fa6c89f..53e92949 100644
--- a/src/syntax/ast.rs
+++ b/src/syntax/ast.rs
@@ -1594,23 +1594,19 @@ node! {
#[derive(Debug, Clone, Hash)]
pub enum Param {
/// A positional parameter: `x`.
- Pos(Ident),
+ Pos(Pattern),
/// A named parameter with a default value: `draw: false`.
Named(Named),
/// An argument sink: `..args`.
Sink(Spread),
- /// A placeholder: `_`.
- Placeholder(Underscore),
}
impl AstNode for Param {
fn from_untyped(node: &SyntaxNode) -> Option<Self> {
match node.kind() {
- SyntaxKind::Ident => node.cast().map(Self::Pos),
SyntaxKind::Named => node.cast().map(Self::Named),
SyntaxKind::Spread => node.cast().map(Self::Sink),
- SyntaxKind::Underscore => node.cast().map(Self::Placeholder),
- _ => Option::None,
+ _ => node.cast().map(Self::Pos),
}
}
@@ -1619,7 +1615,6 @@ impl AstNode for Param {
Self::Pos(v) => v.as_untyped(),
Self::Named(v) => v.as_untyped(),
Self::Sink(v) => v.as_untyped(),
- Self::Placeholder(v) => v.as_untyped(),
}
}
}