I'm having a hard time with file/imports from other files I've written

It gives you exactly one place to find each module

It's precisely the opposite. There was exactly one place before but now with the new way, there are two and you have to check both places. And with mod.rs files, it is (or was, before the addition of a second way to do this) much easier to tell if a module had submodules. If it was a directory, it had submodules, otherwise, it didn't. But if you consistently use mod.rs you still mostly have this benefit.

It makes more semantic sense.

That's somewhat true, I guess, but why should I care that it makes "more sense" if it's less practical. The only thing where this is useful is for beginners and it's not really a big difference since mod.rs really isn't that illogical. Actually, I don't even think the "new" way makes that much more semantic sense. A file having submodules also isn't very logical, and I don't think "mod.rs seems to imply that a module is contained inside its own submodule" is true. You can view mod.rs like an index for the directory and it totally makes sense to put it there, together with the module it describes.

Adding a submodule to an existing module is one step fewer.

How often are you creating submodules (that were originally single file modules!) that this has any importance at all? It's a single drag & drop and rename which takes seconds.

Also, the reality is that the majority of Rust programmers use VSCode and I would assume that you can configure most editors to show a directory prefix for duplicate files. At least you should be able to since this isn't necessarily only an issue with mod.rs files. Similarly, you can of course configure VSCode to change the directory sorting but firstly, mixing files and directories just looks ugly and is less clear in most cases. If anything I would really only want it for Rust source directories but not in general. Secondly, in many places, like for example GitHub or the docs.rs source explorer, it's not configurable. And lastly, this still doesn't solve the issue that it takes up twice as much space.

But really the main benefit to me is that it's just much clearer and logical. Your directory tree directly mirrors your module tree, you can see at a glance which modules have submodules and which don't, and you don't waste

So in conclusion, they introduced a second way to do the same thing which has minimal benefits but in practices is less clear, takes up more space and makes everything more confusing because there are now two ways to do it and you can never be sure anymore at which place to find stuff.

I guess it's obvious that we don't agree which way makes more sense and is clearer which is pretty subjective in the end, I guess, but I hope we can at least agree that having two ways to do exactly the same thing definitely is less clear and more confusing and imo recommending the new way just contributes to this confusion, especially when beginners get recommended and explained something that the majority doesn't do.

/r/rust Thread Parent