Add new trait TypeAscriptionOwner

This trait should be implemented for nodes which have an ascribed type,
e.g. thing : Type. Such as let, const, static, param, named struct fields.
This commit is contained in:
Ville Penttinen 2019-02-26 11:35:57 +02:00
parent 7c9acf2f83
commit 6eb070d661
3 changed files with 36 additions and 9 deletions

View file

@ -31,6 +31,12 @@ pub trait AstToken: AstNode {
}
}
pub trait TypeAscriptionOwner: AstNode {
fn ascribed_type(&self) -> Option<&TypeRef> {
child_opt(self)
}
}
pub trait NameOwner: AstNode {
fn name(&self) -> Option<&Name> {
child_opt(self)