diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/syntax_node.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/ra_syntax/src/syntax_node.rs index 80054f529..89f92e0b7 100644 --- a/crates/ra_syntax/src/syntax_node.rs +++ b/crates/ra_syntax/src/syntax_node.rs | |||
@@ -523,6 +523,10 @@ impl<'a> SyntaxElement<'a> { | |||
523 | } | 523 | } |
524 | } | 524 | } |
525 | 525 | ||
526 | pub fn as_ast_node<T: AstNode>(&self) -> Option<&T> { | ||
527 | self.as_node().and_then(|x| <T as AstNode>::cast(x)) | ||
528 | } | ||
529 | |||
526 | pub fn as_token(&self) -> Option<SyntaxToken<'a>> { | 530 | pub fn as_token(&self) -> Option<SyntaxToken<'a>> { |
527 | match self { | 531 | match self { |
528 | SyntaxElement::Node(_) => None, | 532 | SyntaxElement::Node(_) => None, |