Skip to content

Commit 381ace5

Browse files
committed
Add with_use_tree
1 parent fc4d0a7 commit 381ace5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

crates/ra_syntax/src/ast/edit.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,16 @@ impl ast::PathSegment {
249249
}
250250
}
251251

252+
impl 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+
252262
#[must_use]
253263
pub fn strip_attrs_and_docs<N: ast::AttrsOwner>(node: &N) -> N {
254264
N::cast(strip_attrs_and_docs_inner(node.syntax().clone())).unwrap()

0 commit comments

Comments
 (0)