make stuff private

This commit is contained in:
Aleksey Kladov 2018-12-05 13:20:11 +03:00
parent 4344264024
commit db456749a8
2 changed files with 8 additions and 13 deletions

View file

@ -153,17 +153,10 @@ impl ModuleTree {
self.mods.iter().map(|(id, _)| id)
}
fn modules_for_source(&self, source: ModuleSource) -> Vec<ModuleId> {
self.mods
.iter()
.filter(|(_idx, it)| it.source == source)
.map(|(idx, _)| idx)
.collect()
}
//TODO: move to source binders?
pub(crate) fn any_module_for_source(&self, source: ModuleSource) -> Option<ModuleId> {
self.modules_for_source(source).pop()
pub(crate) fn modules_with_sources<'a>(
&'a self,
) -> impl Iterator<Item = (ModuleId, ModuleSource)> + 'a {
self.mods.iter().map(|(id, m)| (id, m.source))
}
}

View file

@ -61,8 +61,10 @@ fn module_from_source(
) -> Cancelable<Option<Module>> {
let source_root_id = db.file_source_root(module_source.file_id());
let module_tree = db.module_tree(source_root_id)?;
let module_id = ctry!(module_tree.any_module_for_source(module_source));
let m = module_tree
.modules_with_sources()
.find(|(_id, src)| src == &module_source);
let module_id = ctry!(m).0;
Ok(Some(Module::new(db, source_root_id, module_id)?))
}