File and folder naming

Is it true in the Rust project *.rs files (and folders) cannot have random names?

Those depend on modules' naming?

Even main.rs cannot have another name?

Generally yes. There is the [path] attribute you can use to override the default file naming convention for modules.

The crate root file (like src/main.rs or src/lib.rs) is part of a concept of Cargo called targets. You can change the default target configuration in your manifest file (Cargo.toml).

My general advise would be to try to adhere to the defaults as much as possible, it will make your life and the life of your users and collaborators easier.

13 Likes

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.