#Modules working weirdly

4 messages · Page 1 of 1 (latest)

cloud prairie
#

Hi I'm pretty new to rust and I dont relly know how the module system works. I'm setting up a libray so my file structure looks like this,
src
lib.rs
iron_torch.rs
matrix.rs
but when i do this in iron_torch.rs mod matrix; i get this error: error[E0583]: file not found for module matrix
--> src\iron_torch.rs:1:1
|
1 | mod matrix;
| ^^^^^^^^^^^
|
= help: to create the module matrix, create file "src\iron_torch\matrix.rs" or "
src\iron_torch\matrix\mod.rs". but in lib.rs i have this pub mod iron_torch and that works complety fine. Any help is apreciated. Thx in advance!

swift estuary
#

when you put mod matrix in iron_torch.rs it's expecting that to be a sub-module of iron_torch, so it's searching for it in the iron_torch subdirectory.

#

you can create that directory and move the matrix.rs there

#

and then it should work