None
Rust modules seem complicated at first but they are really not

Rust modules easy explanation

Paweł Jankiewicz CTO / Data Scientist Author LinkedIn Profile
2 weeks, 4 days ago · 1 min read Rust

When I first started learning Rust I didn't get how modules work at first. After hanging in Rust discord someone gave me a really good explanation.

Think of modules as a way to include the code from other files. In theory it is possible to create everything in one big file. But no one does it. Splitting modules into files is a good practice to help you maintain your project.

mod test {
    // your code here
}

When you write:

mod utils;

You are asking rust to find the code either in:

Knowing these 2 rules lets you define any module structure in your project.

Paweł Jankiewicz CTO / Data Scientist Author LinkedIn Profile
2 weeks, 4 days ago · 1 min read Rust

Author other articles

Related articles