diff options
author | Ville Penttinen <[email protected]> | 2019-02-26 09:35:57 +0000 |
---|---|---|
committer | Ville Penttinen <[email protected]> | 2019-02-26 09:35:57 +0000 |
commit | 6eb070d6613644b6698a5ce6454d006662c84d8a (patch) | |
tree | 7cf0495a5bccd8ed410aff334e917c833361ba5a /crates/ra_syntax/src/ast.rs | |
parent | 7c9acf2f834c582d9cad4f7d0679a0697c591432 (diff) |
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.
Diffstat (limited to 'crates/ra_syntax/src/ast.rs')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 56fb7c20c..81c709bfb 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -31,6 +31,12 @@ pub trait AstToken: AstNode { | |||
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | pub trait TypeAscriptionOwner: AstNode { | ||
35 | fn ascribed_type(&self) -> Option<&TypeRef> { | ||
36 | child_opt(self) | ||
37 | } | ||
38 | } | ||
39 | |||
34 | pub trait NameOwner: AstNode { | 40 | pub trait NameOwner: AstNode { |
35 | fn name(&self) -> Option<&Name> { | 41 | fn name(&self) -> Option<&Name> { |
36 | child_opt(self) | 42 | child_opt(self) |