From d323c81d5cc6a198239285abcede2166181d8f39 Mon Sep 17 00:00:00 2001
From: Aleksey Kladov <aleksey.kladov@gmail.com>
Date: Tue, 2 Oct 2018 18:02:57 +0300
Subject: make ancestors and descendants inherent

---
 crates/ra_syntax/src/algo/mod.rs | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

(limited to 'crates/ra_syntax/src/algo/mod.rs')

diff --git a/crates/ra_syntax/src/algo/mod.rs b/crates/ra_syntax/src/algo/mod.rs
index 8de44c586..3716a6000 100644
--- a/crates/ra_syntax/src/algo/mod.rs
+++ b/crates/ra_syntax/src/algo/mod.rs
@@ -94,10 +94,6 @@ pub fn find_covering_node(root: SyntaxNodeRef, range: TextRange) -> SyntaxNodeRe
     common_ancestor(left, right)
 }
 
-pub fn ancestors<'a>(node: SyntaxNodeRef<'a>) -> impl Iterator<Item=SyntaxNodeRef<'a>> {
-    generate(Some(node), |&node| node.parent())
-}
-
 #[derive(Debug)]
 pub enum Direction {
     Forward,
@@ -115,8 +111,8 @@ pub fn siblings<'a>(
 }
 
 fn common_ancestor<'a>(n1: SyntaxNodeRef<'a>, n2: SyntaxNodeRef<'a>) -> SyntaxNodeRef<'a> {
-    for p in ancestors(n1) {
-        if ancestors(n2).any(|a| a == p) {
+    for p in n1.ancestors() {
+        if n2.ancestors().any(|a| a == p) {
             return p;
         }
     }
-- 
cgit v1.2.3


From 1a2a8dec14ec04ea8eeccae99fd885e7a280e45b Mon Sep 17 00:00:00 2001
From: Aleksey Kladov <aleksey.kladov@gmail.com>
Date: Tue, 2 Oct 2018 18:14:33 +0300
Subject: Make siblings an inherent method

---
 crates/ra_syntax/src/algo/mod.rs | 16 ----------------
 1 file changed, 16 deletions(-)

(limited to 'crates/ra_syntax/src/algo/mod.rs')

diff --git a/crates/ra_syntax/src/algo/mod.rs b/crates/ra_syntax/src/algo/mod.rs
index 3716a6000..a6678093d 100644
--- a/crates/ra_syntax/src/algo/mod.rs
+++ b/crates/ra_syntax/src/algo/mod.rs
@@ -94,22 +94,6 @@ pub fn find_covering_node(root: SyntaxNodeRef, range: TextRange) -> SyntaxNodeRe
     common_ancestor(left, right)
 }
 
-#[derive(Debug)]
-pub enum Direction {
-    Forward,
-    Backward,
-}
-
-pub fn siblings<'a>(
-    node: SyntaxNodeRef<'a>,
-    direction: Direction
-) -> impl Iterator<Item=SyntaxNodeRef<'a>> {
-    generate(Some(node), move |&node| match direction {
-        Direction::Forward => node.next_sibling(),
-        Direction::Backward => node.prev_sibling(),
-    })
-}
-
 fn common_ancestor<'a>(n1: SyntaxNodeRef<'a>, n2: SyntaxNodeRef<'a>) -> SyntaxNodeRef<'a> {
     for p in n1.ancestors() {
         if n2.ancestors().any(|a| a == p) {
-- 
cgit v1.2.3