Allow to disable import insertion on single path glob imports

This commit is contained in:
Lukas Wirth 2021-06-18 23:11:56 +02:00
parent 84507a0b9c
commit 2ee090faaf
14 changed files with 99 additions and 17 deletions

View file

@ -281,6 +281,15 @@ impl ast::Path {
successors(self.qualifier(), |p| p.qualifier())
}
}
impl ast::Use {
pub fn is_simple_glob(&self) -> bool {
self.use_tree()
.map(|use_tree| use_tree.use_tree_list().is_none() && use_tree.star_token().is_some())
.unwrap_or(false)
}
}
impl ast::UseTree {
pub fn is_simple_path(&self) -> bool {
self.use_tree_list().is_none() && self.star_token().is_none()