0
votes

My code tree.

src :

 main.rs
 modA    :
           mod.rs
           a.rs

main.rs :

mod modA;
fn main() {
    println!("Hello, world!");
}

mod.rs :

pub mod a;

a.rs : dummy function

This code compile.

But I have understood that I should write in mains.rs

use mod modA

instead of

mod modA

; (as it indicated in this link :https://doc.rust-lang.org/reference/items/use-declarations.html) But the compilator has said :unresolved import.

Should I keep the code as he currently is or should I do otherwise?

1

1 Answers

1
votes

That's not quite right, you should only use the use keyword to prevent having to type full path to items within the sub module in other modules outside main. To pull the submodule into the hierarchy, your first approach was correct:

mod modA