3480: Add with_use_tree r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-03-05 17:39:30 +00:00 committed by GitHub
commit 6131cf32bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -249,6 +249,16 @@ impl ast::PathSegment {
}
}
impl ast::UseItem {
#[must_use]
pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::UseItem {
if let Some(old) = self.use_tree() {
return replace_descendants(self, iter::once((old, use_tree)));
}
self.clone()
}
}
#[must_use]
pub fn strip_attrs_and_docs<N: ast::AttrsOwner>(node: &N) -> N {
N::cast(strip_attrs_and_docs_inner(node.syntax().clone())).unwrap()