Added use include
This commit is contained in:
@@ -26,10 +26,15 @@ pub trait GetRust {
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Include {
|
||||
Glob(Path),
|
||||
Use(Visibility, Path),
|
||||
}
|
||||
|
||||
pub struct RustCodegen {
|
||||
output: String,
|
||||
indent: usize,
|
||||
pub crates: HashMap<Identifier, Vec<Path>>,
|
||||
pub crates: HashMap<Identifier, Vec<Include>>,
|
||||
pub mapping: Mapping,
|
||||
position: RustMap,
|
||||
}
|
||||
@@ -101,8 +106,17 @@ impl RustCodegen {
|
||||
|
||||
for item in items {
|
||||
self.add_indented("pub use ");
|
||||
item.gen_rust(&mut ctx, self);
|
||||
self.addln("::*;");
|
||||
match item {
|
||||
Include::Glob(item) => {
|
||||
item.gen_rust(&mut ctx, self);
|
||||
self.add("::*");
|
||||
}
|
||||
Include::Use(vis, item) => {
|
||||
vis.gen_rust(&mut ctx, self);
|
||||
item.gen_rust(&mut ctx, self);
|
||||
}
|
||||
}
|
||||
self.addln(";");
|
||||
}
|
||||
|
||||
self.indent -= 1;
|
||||
|
||||
@@ -330,7 +330,13 @@ impl GenRust for TopLevelKind {
|
||||
cg.crates
|
||||
.entry(incl.0[0].clone())
|
||||
.or_insert(Vec::new())
|
||||
.push(incl.clone());
|
||||
.push(crate::Include::Glob(incl.clone()));
|
||||
}
|
||||
Self::IncludeUse(vis, incl) => {
|
||||
cg.crates
|
||||
.entry(incl.0[0].clone())
|
||||
.or_insert(Vec::new())
|
||||
.push(crate::Include::Use(vis.clone(), incl.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user