Issue with imports

This is link to my project's main.rs: idewave-cli/src/main.rs at primary · idewave/idewave-cli · GitHub

I decided to refactor the code and one of my tasks is to change directory structure. So, I want to move core functionality (all directories except ui) to the "primary" directory and extra functionality like "UI" to the "features" dir. And after I did this and fixed imports paths, I found that this line is not work:

extern crate primary;

I got the error:

error[E0463]: can't find crate for `primary`
 --> src/main.rs:2:1
  |
2 | extern crate primary;
  | ^^^^^^^^^^^^^^^^^^^^^ can't find crate

I use "extern" to avoid using "use" for each file separately.

Could somebody help me to fix this path issue and expain what I did wrong ?

What is "extern crate primary;" supposed to do? You don't have a dependency named "primary", and (just in case you're confusing crates & modules) there's no file or directory in src/ named "primary" or "primary.rs".

Also, note that including extern crate foo; in your code has been unnecessary since Rust's 2018 edition was released, and your Cargo.toml states that you're using the 2021 edition, so you should be able to get rid of all of those extern crate lines to begin with.

3 Likes

Thank you for an answer. I just had a pause with Rust and was confused for a first time. Yep, I do not need to use extern here. Just need to use "mod primary" after move all dirs to "primary" dir and fix the path.

1 Like