Add default type param in TypeParam Node

This commit is contained in:
Edwin Cheng 2019-05-03 12:18:35 +08:00
parent 9901f3e45e
commit 9e4fee8b41
3 changed files with 8 additions and 1 deletions

View File

@ -4038,6 +4038,7 @@ impl ToOwned for TypeParam {
impl ast::NameOwner for TypeParam {}
impl ast::AttrsOwner for TypeParam {}
impl ast::TypeBoundsOwner for TypeParam {}
impl ast::DefaultTypeParamOwner for TypeParam {}
impl TypeParam {}
// TypeParamList

View File

@ -152,3 +152,9 @@ impl<'a> Iterator for CommentIter<'a> {
self.iter.by_ref().find_map(|el| el.as_token().and_then(ast::Comment::cast))
}
}
pub trait DefaultTypeParamOwner: AstNode {
fn default_type(&self) -> Option<&ast::PathType> {
child_opt(self)
}
}

View File

@ -563,7 +563,7 @@ Grammar(
["lifetime_params", "LifetimeParam" ],
]
),
"TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner"] ),
"TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner", "DefaultTypeParamOwner"] ),
"LifetimeParam": (
traits: ["AttrsOwner"],
),