Roman Mahotskyi
Roman Mahotskyi

Reputation: 6625

How to declare a module which has a dot in a file name?

I would like to add suffixes to the name of file modules

module1/
- mod.rs
- module.suffix1.rs
- module.suffix2.rs
- module.suffix3.rs
main.rs
// module1/mod.rs

pub use module.seuffix1;
              ^ Error

pub use module.suffix2;
              ^ Error

pub use module.suffix3;
              ^ Error

How can I achieve this?

P.S. I'm not sure if this convention is "okay" in rust, but module_suffix2.rs looks messy when a file name consists of two words - my_modyle_suffix.rs

Upvotes: 1

Views: 1139

Answers (1)

Chayim Friedman
Chayim Friedman

Reputation: 71005

You cannot include dots in names. You can create a module module and have suffix, suffix2 and suffix3 as submodules, accessing them with module::suffix. If you prefer to keep the directory structure flat, you can use the #[path] attribute.

Upvotes: 1

Related Questions