I've been learning about the Rust module system this weekend. All was going well until I decided to split my sub module to a separate file.
Original: src/lib.rs
pub mod literal {
use crate::literal::sub_literal::MyStruct;
fn my_fun() {
let a = MyStruct{num: 43};
}
mod sub_literal {
pub struct MyStruct {
pub num: u32,
}
}
}
With the mod sub_literal code now in src/literal/sub_literal.rs my use line needs to be, with an extra sub_literal in there.
use crate::literal::sub_literal::sub_literal::MyStruct;
Took me a bit to figure it out. Why the extra layer? Time for another read of the docs no doubt!