blob: fb298a315d8e6bee61e752e23476aa0101be156d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
use libsyntax2::{
SmolStr,
ast::{self, NameOwner},
};
#[derive(Debug, Hash)]
pub struct ModuleDescr {
pub submodules: Vec<Submodule>
}
impl ModuleDescr {
pub fn new(root: ast::Root) -> ModuleDescr {
let submodules = root
.modules()
.filter_map(|module| {
let name = module.name()?.text();
if !module.has_semi() {
return None;
}
Some(Submodule { name })
}).collect();
ModuleDescr { submodules } }
}
#[derive(Clone, Hash, PartialEq, Eq, Debug)]
pub struct Submodule {
pub name: SmolStr,
}
|