Rename `` to ``

I like having the module file inside it's directory but code editors sort files alphabetically, which mixes with other files and can't be found at a glance.

+---foo	<-- far away from `/foo`, mixed with other files, weird
+---foo	<-- right below foo/, above all files, makes sense

I found here that using [#path="foo/"] was possible...

mod foo;

fn main() {

...but I would need to write that for every import in a file.

Is there a way to configure Cargo to recognise as a module instead of

(if this is possible for bin/,, or other similar file/dir name, that would be cool too)


You can also rename foo/ to just without having to do anything else special.


That's true, but It doesn't fix the problem that the module file and directory aren't next to one another.

| 	<-- far away from `/foo`, mixed with other files, weird

...unless you sort alphabetically with no separation between files and directories (in VSCode: "explorer.sortOrder": "mixed") which just looks very wrong to me.

1 Like

What an awesome insight. I spent lots of time looking for, and files in folders and have not realized such an easy solution could exist. The Sass compiler already allows to use underscore prefixes and just ignores them from the module name.

1 Like

This could also be handled at the IDE level. intellij-rust already sorts first (in some windows), but not or any others.


1 Like

Using is an interesting idea.

If ergonomics are the issue, one can define a (proc1-)macro that does the #[path = ...] for you:


// expands to
#[path = "bar/"]
mod bar;

What do you think of that?

1 Curiously a non procedural macro does not work.

1 Like

Yeah, custom sort order in the editor would be perfect. Unfortunately, VSCode doesn't support it yet.

This is sooort of off-topic, but I wonder: are you (or have you ever been grin) a Windows user?

Having gotten used to intermixed files and directories (in macOS and Linux) the Windows collation scheme looks very wrong to me! (honestly, it kind of drives me crazy.)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.