1

I know that you can have multiple modules in a single file using the mod keyword. I know that you can also split a module across several files using the file structure described in the tutorial:

├── english
│   ├── farewells.rs
│   ├── greetings.rs
│   └── mod.rs

I am looking for a mix of these functionalities. Specifically, I have a set of modules in separate files:

.
├── main.rs
├── constant.rs // module
├── function.rs // module
├── matrix.rs   // module
└── ops.rs      // module, but probably shouldn't be

These are separate modules, but I would prefer to only have constant.rs, function.rs, and matrix.rs be modules and to have ops.rs simply augment these three modules. The objective is to allow ops.rs to access private methods in those three modules. Right now I have to make those methods public, which is undesirable.

I'm looking for something similar to Ruby mixins or C++ 'friend' functions.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
ethanabrooks
  • 747
  • 8
  • 19

0 Answers0