importing a module is the most fustrating part of writing rust code next to writing a multiple-spawn tasks.
Can someone help me how to import a module in lib/m.rs from lib.rs ? I've never seen someone asked about it.
Can someone help me how to import a module in lib/m.rs from lib.rs ? I've never seen someone asked about it.
src/lib.rs
lib/
mod.rs
m.rs
In lib.rs use lib::m;
In lib/mod.rs pub mod m;
You need the mod.rs file in subdirectories.First, the `mod` keyword takes a module that the current file/scope can see and makes it available within that file/scope as if it had been defined there. This is necessary to make the module's items accessible, i.e., specifiable by their path within the module, in the current file/scope.
Then the `use` keyword takes an already-accessible member of a named scope -- a module, a type, etc -- and makes it usable by name (i.e., without scoping on each use) in the current scope.