diff options
Diffstat (limited to 'crates/ra_syntax/src/algo.rs')
-rw-r--r-- | crates/ra_syntax/src/algo.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs index 2b2b295f9..30a479f01 100644 --- a/crates/ra_syntax/src/algo.rs +++ b/crates/ra_syntax/src/algo.rs | |||
@@ -184,17 +184,17 @@ pub fn replace_children( | |||
184 | /// to create a type-safe abstraction on top of it instead. | 184 | /// to create a type-safe abstraction on top of it instead. |
185 | pub fn replace_descendants( | 185 | pub fn replace_descendants( |
186 | parent: &SyntaxNode, | 186 | parent: &SyntaxNode, |
187 | map: &FxHashMap<SyntaxElement, SyntaxElement>, | 187 | map: &impl Fn(&SyntaxElement) -> Option<SyntaxElement>, |
188 | ) -> SyntaxNode { | 188 | ) -> SyntaxNode { |
189 | // FIXME: this could be made much faster. | 189 | // FIXME: this could be made much faster. |
190 | let new_children = parent.children_with_tokens().map(|it| go(map, it)).collect::<Vec<_>>(); | 190 | let new_children = parent.children_with_tokens().map(|it| go(map, it)).collect::<Vec<_>>(); |
191 | return with_children(parent, new_children); | 191 | return with_children(parent, new_children); |
192 | 192 | ||
193 | fn go( | 193 | fn go( |
194 | map: &FxHashMap<SyntaxElement, SyntaxElement>, | 194 | map: &impl Fn(&SyntaxElement) -> Option<SyntaxElement>, |
195 | element: SyntaxElement, | 195 | element: SyntaxElement, |
196 | ) -> NodeOrToken<rowan::GreenNode, rowan::GreenToken> { | 196 | ) -> NodeOrToken<rowan::GreenNode, rowan::GreenToken> { |
197 | if let Some(replacement) = map.get(&element) { | 197 | if let Some(replacement) = map(&element) { |
198 | return match replacement { | 198 | return match replacement { |
199 | NodeOrToken::Node(it) => NodeOrToken::Node(it.green().clone()), | 199 | NodeOrToken::Node(it) => NodeOrToken::Node(it.green().clone()), |
200 | NodeOrToken::Token(it) => NodeOrToken::Token(it.green().clone()), | 200 | NodeOrToken::Token(it) => NodeOrToken::Token(it.green().clone()), |