How can I import my project/src/modules inside my project/examples?


My project looks like :

  1. modules
  1. examples

And I want to import the modules inside my examples but I found no documentation about this + my understanding about import mechanics is not danky.

Thanks in advance :smiley:

Doesn't use crate_name::module1; work?

@H2CO3 's suggestion will work assuming that you have a which declares mod module1;.

If that's not your goal, or it still doesn't work, please share the entire file listing of your project, and what errors you get.


As @kpreid said, the solution was including a project/src/ file containing these lines.

pub mod module1;
pub mod module2;

And then importing these modules inside my project/examples/ like this :

use project::module1;
use project::module2;

Special thanks to @Yandros who gave me the full solution.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.