aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/mod.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/mod.rs b/crates/ra_syntax/src/ast/mod.rs
index d93f92672..6b0d62610 100644
--- a/crates/ra_syntax/src/ast/mod.rs
+++ b/crates/ra_syntax/src/ast/mod.rs
@@ -296,6 +296,15 @@ impl<'a> PathSegment<'a> {
296 } 296 }
297} 297}
298 298
299impl<'a> UseTreeList<'a> {
300 pub fn parent_use_tree(self) -> UseTree<'a> {
301 self.syntax()
302 .parent()
303 .and_then(UseTree::cast)
304 .expect("UseTreeLists are always nested in UseTrees")
305 }
306}
307
299fn child_opt<'a, P: AstNode<'a>, C: AstNode<'a>>(parent: P) -> Option<C> { 308fn child_opt<'a, P: AstNode<'a>, C: AstNode<'a>>(parent: P) -> Option<C> {
300 children(parent).next() 309 children(parent).next()
301} 310}