google / alioth

Experimental KVM-based type-2 hypervisor in Rust implemented from scratch.
Apache License 2.0
164 stars 10 forks source link

style: use `foo/foo.rs` as module paths #8

Closed Lencerf closed 7 months ago

Lencerf commented 7 months ago

Rust 2018 introduced a new directory structure foo.rs + foo/bar.rs to replace the old foo/mod.rs + foo/bar.rs for a module foo with submodule bar. While it solved the issue of "a bunch of tabs named mod.rs", it introduced a new problem. If a lib has multiple modules with submodules, most file browsers list directories before files,

├── lib.rs
├── foo1
│   └── bar1.rs
├── foo2
│   └── bar2.rs
├── foo3
│   └── bar3.rs
├── foo1.rs
├── foo2.rs
└── foo3.rs

and thus visually foo1 is far from foo1.rs.

This commit introduces a customized file hierarchy: for a module foo and its submodule bar, we place the source code in foo/foo.rs and foo/bar.rs respectively, so we can avoid mod.rs and also put source files of a module in a single directory.

For sure this breaks the community convention and we have to use the path attribute every time.