Currently, it's not possible to re-export private modules. This code is not valid
fn main() {
let hello = file::iMod::Hello {
name: String::from("Omar")
};
dbg!(hello);
}
mod file {
mod myMod {
#[derive(Debug)]
pub struct Hello {
pub name: String,
}
}
pub use myMod as iMod;
}
However, it's still possible to export the Hello
struct
fn main() {
let hello = file::iHello {
name: String::from("Omar")
};
dbg!(hello);
}
mod file {
mod myMod {
#[derive(Debug)]
pub struct Hello {
pub name: String,
}
}
pub use myMod::Hello as iHello;
}
Since you can export everything inside myMod
, I think it makes sense to make it possible to re-export private modules?
Use Case: Some libraries generate modules with Derive
. I would like to use these modules and the structs inside them in other parts of the code. It's not possible to add the pub keyword since this code is auto-generated (or is it?).