@@ -551,6 +551,36 @@ impl ConstDef {
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ConstParam {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl AstNode for ConstParam {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
CONST_PARAM => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode {
|
||||
&self.syntax
|
||||
}
|
||||
}
|
||||
impl ast::NameOwner for ConstParam {}
|
||||
impl ast::AttrsOwner for ConstParam {}
|
||||
impl ast::TypeAscriptionOwner for ConstParam {}
|
||||
impl ConstParam {
|
||||
pub fn default_val(&self) -> Option<Expr> {
|
||||
AstChildren::new(&self.syntax).next()
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ContinueExpr {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
|
||||
@@ -243,6 +243,7 @@ Grammar(
|
||||
"TYPE_PARAM_LIST",
|
||||
"LIFETIME_PARAM",
|
||||
"TYPE_PARAM",
|
||||
"CONST_PARAM",
|
||||
"TYPE_ARG_LIST",
|
||||
"LIFETIME_ARG",
|
||||
"TYPE_ARG",
|
||||
@@ -602,6 +603,10 @@ Grammar(
|
||||
options: [("default_type", "TypeRef")],
|
||||
traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner"],
|
||||
),
|
||||
"ConstParam": (
|
||||
options: [("default_val", "Expr")],
|
||||
traits: ["NameOwner", "AttrsOwner", "TypeAscriptionOwner"],
|
||||
),
|
||||
"LifetimeParam": (
|
||||
traits: ["AttrsOwner"],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user