0

The question is simple: Why can't I use use crate::utils?

If I understood correctly, the crate refers to the root of my crate. I've just generated a new library project that by default has a lib.rs and utils.rs file and although I understand why mod utils work, I don't understand why use crate::utils wouldn't.

Amanda Ferrari
  • 1,168
  • 5
  • 17
  • 30
  • 2
    You need `mod utils;` for `utils.rs` to be even considered a part of the project by the compiler. If you don't declare that module, the file will be ignored, and there simply isn't any `crate::utils` to be used. – Sven Marnach Oct 08 '20 at 14:44
  • 1
    Does this answer your question? [Split a module across several files](https://stackoverflow.com/questions/22596920/split-a-module-across-several-files) – E_net4 Oct 08 '20 at 15:05
  • Does this answer your question? [How to use structures from sibling/adjacent rust file?](https://stackoverflow.com/questions/61947573/how-to-use-structures-from-sibling-adjacent-rust-file) – Jmb Oct 09 '20 at 06:46

0 Answers0