From 6eb070d6613644b6698a5ce6454d006662c84d8a Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Tue, 26 Feb 2019 11:35:57 +0200 Subject: 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. --- crates/ra_syntax/src/ast.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates/ra_syntax/src/ast.rs') 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 { } } +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) -- cgit v1.2.3