aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r--crates/ra_hir_expand/src/lib.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index 2fa5d5140..51c5f9623 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -322,3 +322,13 @@ impl InFile<SyntaxNode> {
322 }) 322 })
323 } 323 }
324} 324}
325
326impl<N: AstNode> InFile<N> {
327 pub fn descendants<T: AstNode>(self) -> impl Iterator<Item = InFile<T>> {
328 self.value.syntax().descendants().filter_map(T::cast).map(move |n| self.with_value(n))
329 }
330
331 pub fn syntax(&self) -> InFile<&SyntaxNode> {
332 self.with_value(self.value.syntax())
333 }
334}