I'm not sure why you are getting this error for sure, but it wonβt do what you want. Modules form a tree structure, and you use mod declarations to form them. So you are trying to create another mod2 in file3.
I assume that you want the files file2 and file3 to be under the main module, and not with additional modules of each other. To do this, put
mod file2; mod file3;
In lib.rs and then in file3.rs
use file2::Struct2;
And everything should work. I am on a mobile phone, so I canβt check myself three times, sorry for the formatting.
source share