#Failing to understand mod and use

4 messages · Page 1 of 1 (latest)

elfin bramble
#

Hi everyone,

I've been trying to understand how use and mod works.

My project looks like this:
src/
main.rs
lib.rs
configuration.rs
endpoints/
nodes.rs

in my main.rs I can do a use cratename::configuration::get_config;
If I try that in my endpoints/nodes.rs it works as well... But...

If I now want to use endpoints/nodes/get_nodes()
use cratename::endpoints::nodes::get_nodes;

It cannot find the endpoints in cratename... fine I'll do what I've found about it so far:
in lib.rs I setup
pub mod configuration;
pub mod endpoints;

endpoints is complaining, so I add:
endpoints/mod.rs
mod nodes;
pub use nodes::*;

And yes, now I can use the functions in nodes.rs in main, but it broke configuration in the nodes.rs, suddenly it can't access it and no matter how I try. I can't get it to use it after I've set a mod.rs in the endpoints dir.

When reading up on it, it seems simple enough, but no matter how I try it refuses.

hidden quiver
#

-module

#

-modules

reef relicBOT