I keep on running into the following inconvenience and wonder if there is a better solution.
Current solution:
1. fire up terminal from current file
2. mkdir foo
3. mv foo.rs foo/mod.rs
Is there an IntelliJ shortcut / a way to script this in IntelliJ to do "foo.rs => foo/mod.rs" ?
This isn't really an answer to your question, but did you know you can have a
src
|_main.rs
|_foo.rs
|_foo
|_foo_submodule.rs
instead of
src
|_main.rs
|_foo
|_mod.rs
|_foo_submodule.rs
point being you don't need to rename and move the file to have submodules for it anyway if you make modules with this structure.
As for your original question, I saw this in Intellij Rust usage
RefactoringsWIP
Expand module : invoke this refactoring inside foo.rs file to get foo/mod.rs . Also available as a quick fix for unresolved module declaration.
https://intellij-rust.github.io/features/
I don't know if there's a keyboard shortcut, but you can right click on the foo.rs and there should be a "Promote to directory module" entry or something like that in the "Refactor" submenu.