Avatar ·

What is the mod.rs file for in Rust? Explain with an example

Hello! I just started learning Rust and am trying to understand code organization. I noticed that in many Rust projects there are folders containing a mod.rs file. For example, I saw this structure: ``` src/ main.rs utils/ mod.rs helpers.rs ``` I tried just creating a folder and putting files with functions in it, but the compiler complains if there is no mod.rs. At the same time, I read that in newer versions of Rust you can use something else. Please tell me: 1. Why is mod.rs needed? 2. What does it do? 3. How to properly declare modules? 4. Are there alternatives in modern Rust? Here is an example of my code that doesn't work: ```rust // main.rs mod utils; // error: cannot find module fn main() { utils::say_hello(); } ``` In the utils folder there is a file hel