The #1 goal for Rust (edit: this year) is to lower the learning curve. If people hit modules on their learning curve, then that is the reason to make modules simpler to use.
While mod foo {}
in itself sounds easy, it doesn't exist in a vacuum. It exists alongside use
, and they are not orthogonal features, which makes it confusing, e.g.
- in the root of the crate you write
mod foo;
, and can't writeuse foo;
, - but elsewhere you write
use foo;
, and can't writemod foo;
.
This is specific to Rust, and it looks weird and arbitrary from perspective of JS, Python or Java, which don't have this distinction.
I stumbled upon this, and it just added to my frustration with Rust. I did read the book, I did ask on IRC. Eventually I got it, but it was a waste of time for everybody.
Rust can't exist in practice without use
, but mod
can easily be removed from the list of things a novice has to know in order to use the language.