I've tried a few things now but I'm rather confused how to break up some of my code...
Basically I want to have 3 types, and they all depend on the previous ones in a chain.
LabelData
->Node
-> SuffixTree
Now I was thinking that I could just do the following in my file system
src
* types
* * label_data.rs
* * node.rs
* * suffix_tree.rs
* lib.rs
label_data.rs
does not require any other modules, so no mod
's in that.
In node.rs
I was thinking I could just do
mod label_data;
[...]
And in suffix_tree.rs
mod label_data;
mod node;
[...]
However I am getting plenty of errors trying this.. I cannot use any mod
in lib.rs
at all. I read that I could make a types.rs
in the same folder as lib.rs
so I also tried that.
types.rs
is just the following...
pub mod label_data;
pub mod node;
pub mod suffix_tree;
And that works for importing things in lib.rs
now as
mod types;
use types::suffix_tree::SuffixTree;
[...]
But I now get errors in the individual files about node.rs
not being able to find mod label_data
and the suffix_tree.rs
cannot find either of them as well.
Coming from a C# background (harsh I know), the import and namespaces just seem to "work" but I think I am not understanding how these modules and their visibility works. So I am asking for help in clarifying this, and maybe how to sort all this Separation of Concerns out into smaller and cleaner files for this particular example.