diff options
Diffstat (limited to 'crates/ra_syntax/src/algo')
-rw-r--r-- | crates/ra_syntax/src/algo/visit.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/ra_syntax/src/algo/visit.rs b/crates/ra_syntax/src/algo/visit.rs index 81a99228f..87bd15cc0 100644 --- a/crates/ra_syntax/src/algo/visit.rs +++ b/crates/ra_syntax/src/algo/visit.rs | |||
@@ -16,7 +16,7 @@ pub trait Visitor<'a>: Sized { | |||
16 | fn visit<N, F>(self, f: F) -> Vis<Self, N, F> | 16 | fn visit<N, F>(self, f: F) -> Vis<Self, N, F> |
17 | where | 17 | where |
18 | N: AstNode + 'a, | 18 | N: AstNode + 'a, |
19 | F: FnOnce(&'a N) -> Self::Output, | 19 | F: FnOnce(N) -> Self::Output, |
20 | { | 20 | { |
21 | Vis { inner: self, f, ph: PhantomData } | 21 | Vis { inner: self, f, ph: PhantomData } |
22 | } | 22 | } |
@@ -29,7 +29,7 @@ pub trait VisitorCtx<'a>: Sized { | |||
29 | fn visit<N, F>(self, f: F) -> VisCtx<Self, N, F> | 29 | fn visit<N, F>(self, f: F) -> VisCtx<Self, N, F> |
30 | where | 30 | where |
31 | N: AstNode + 'a, | 31 | N: AstNode + 'a, |
32 | F: FnOnce(&'a N, Self::Ctx) -> Self::Output, | 32 | F: FnOnce(N, Self::Ctx) -> Self::Output, |
33 | { | 33 | { |
34 | VisCtx { inner: self, f, ph: PhantomData } | 34 | VisCtx { inner: self, f, ph: PhantomData } |
35 | } | 35 | } |
@@ -74,13 +74,13 @@ impl<'a, V, N, F> Visitor<'a> for Vis<V, N, F> | |||
74 | where | 74 | where |
75 | V: Visitor<'a>, | 75 | V: Visitor<'a>, |
76 | N: AstNode + 'a, | 76 | N: AstNode + 'a, |
77 | F: FnOnce(&'a N) -> <V as Visitor<'a>>::Output, | 77 | F: FnOnce(N) -> <V as Visitor<'a>>::Output, |
78 | { | 78 | { |
79 | type Output = <V as Visitor<'a>>::Output; | 79 | type Output = <V as Visitor<'a>>::Output; |
80 | 80 | ||
81 | fn accept(self, node: &'a SyntaxNode) -> Option<Self::Output> { | 81 | fn accept(self, node: &'a SyntaxNode) -> Option<Self::Output> { |
82 | let Vis { inner, f, .. } = self; | 82 | let Vis { inner, f, .. } = self; |
83 | inner.accept(node).or_else(|| N::cast(node).map(f)) | 83 | inner.accept(node).or_else(|| N::cast(node.clone()).map(f)) |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
@@ -95,14 +95,14 @@ impl<'a, V, N, F> VisitorCtx<'a> for VisCtx<V, N, F> | |||
95 | where | 95 | where |
96 | V: VisitorCtx<'a>, | 96 | V: VisitorCtx<'a>, |
97 | N: AstNode + 'a, | 97 | N: AstNode + 'a, |
98 | F: FnOnce(&'a N, <V as VisitorCtx<'a>>::Ctx) -> <V as VisitorCtx<'a>>::Output, | 98 | F: FnOnce(N, <V as VisitorCtx<'a>>::Ctx) -> <V as VisitorCtx<'a>>::Output, |
99 | { | 99 | { |
100 | type Output = <V as VisitorCtx<'a>>::Output; | 100 | type Output = <V as VisitorCtx<'a>>::Output; |
101 | type Ctx = <V as VisitorCtx<'a>>::Ctx; | 101 | type Ctx = <V as VisitorCtx<'a>>::Ctx; |
102 | 102 | ||
103 | fn accept(self, node: &'a SyntaxNode) -> Result<Self::Output, Self::Ctx> { | 103 | fn accept(self, node: &'a SyntaxNode) -> Result<Self::Output, Self::Ctx> { |
104 | let VisCtx { inner, f, .. } = self; | 104 | let VisCtx { inner, f, .. } = self; |
105 | inner.accept(node).or_else(|ctx| match N::cast(node) { | 105 | inner.accept(node).or_else(|ctx| match N::cast(node.clone()) { |
106 | None => Err(ctx), | 106 | None => Err(ctx), |
107 | Some(node) => Ok(f(node, ctx)), | 107 | Some(node) => Ok(f(node, ctx)), |
108 | }) | 108 | }) |