aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-05 17:39:30 +0000
committerGitHub <[email protected]>2020-03-05 17:39:30 +0000
commit6131cf32bc3c0a71be42a0d1b09e096b10e9ba0d (patch)
treeaaec4f98940764b36eae58b46c95123539b4943f /crates/ra_syntax
parentc3a349bfe986638582249629aa757ba5fe2a3888 (diff)
parent381ace587eb1629019d5d07eba571ddc9d27cc08 (diff)
Merge #3480
3480: Add with_use_tree r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/edit.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index d2630e9e9..1858e2b6c 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -249,6 +249,16 @@ impl ast::PathSegment {
249 } 249 }
250} 250}
251 251
252impl ast::UseItem {
253 #[must_use]
254 pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::UseItem {
255 if let Some(old) = self.use_tree() {
256 return replace_descendants(self, iter::once((old, use_tree)));
257 }
258 self.clone()
259 }
260}
261
252#[must_use] 262#[must_use]
253pub fn strip_attrs_and_docs<N: ast::AttrsOwner>(node: &N) -> N { 263pub fn strip_attrs_and_docs<N: ast::AttrsOwner>(node: &N) -> N {
254 N::cast(strip_attrs_and_docs_inner(node.syntax().clone())).unwrap() 264 N::cast(strip_attrs_and_docs_inner(node.syntax().clone())).unwrap()