Hello!
I am new to rust. I have read the relevant section of the crab book several times, but still cannot figure this out. I want to separate my program into multiple files. This seems really straightforward and simple, but I have have been really struggling with this and trying many things. I think that this is what I want.
I want to have /main.rs for the main logic of the program.
I want to have a module that contains functions used by the program, where those functions are not attached to any struct. I would like to call this module wsl. I assume that this would be /wsl.rs, /lib.rs, /wsl/wsl.rs, /wsl/lib.rs, or something along those lines. I have found at least one variant that works for this, so then I can call my method as wsl::function().
To me logically, the structs used by that wsl module belong in a subdirectory related to that module name. For example, if the methods are in /wsl/lib.rs, then the types would go in /wsl/types/.rs, or /wsl/.rs, or something like that. The module and the program should be able to use these structs. No matter what I do, rust cannot seem to find these structs.
So I want to have a wsl:: path with methods and use wsl::typename or wsl::scope::typename for my types.
I am looking for suggestions for:
-whether I am thinking about this wrongly
-where to put the files and what to name them
-specific code to put in each file to make this work
It all works fine if I put everything in the same file or separate files in a directory without nesting, but I do not consider that to be very good practice, although rust seems to suggest this approach. I do not intend to complain, and in fact I like many things about rust, but some of these little details are incredibly frustrating and the examples do not provide great coverage of what I consider to be some of the most common use cases for programmers, such as this one. Also, I may be misinterpreting, but it seems odd, confusing, and risky that rust appears to use the file path to determine module names rather than using anything in the code itself. I would like to specify my module names in code, whether they match file paths or not.
Thanks & regards,
-Roberto