Using File hierarchy

Hi everybody,
I am trying to split in different files a models.rs file which contains all the structs of my database
So I create a directory models which contains the different files for each structs
I have read the documentation but It seems to be more complex
The compiler says:
unresolved import models::MyappPathology**
use models::MyappPathology;
no MyappPathology in models**

This file exists
Please help to understand how it works

Best Regards

Didier

  1. Make sure there's only one mod models in the whole program. Every module must be created exactly once (mod behaves exactly like fn and struct).

  2. Use crate::models to refer to src/models.rs which has been created by putting mod models; in src/lib.rs.

  3. Ensure there's pub struct MyappPathology in src/models.rs. Specifically the pub part.

Thanks,
I have checked there is one mod models in the whole program

I solve the problem by creating a file mod.rs in models directory which contains
pub mod MyappPathology;

Thanks

In the documentation, it is suggested not to specify a mod.rs file with the name of the module

But without the file mod.rs in the subdirectory models
It is not working

Oh, I thought MyappPathology was meant to be a struct. Rust's naming scheme suggests using all-lowercase names for modules.

Ok I change the name and use lowercase

if you want crate::modules::myapp_pathology::SomeStructName to work, then all the modules in the path must exist, so both mod modules in src/lib.rs, and then mod myapp_pathology in src/modules.rs or src/modules/mod.rs, and then it'll make a module from src/modules/myapp_pathology.rs.

You must declare every module, but you don't have to have a file on disk for every module. Instead of mod modules; loaded from file, you can have mod modules { /* content of the file goes here */ }