diff --git a/src/rust-2018/module-system/path-clarity.md b/src/rust-2018/module-system/path-clarity.md index e4522c78..19bbf739 100644 --- a/src/rust-2018/module-system/path-clarity.md +++ b/src/rust-2018/module-system/path-clarity.md @@ -169,10 +169,8 @@ mod submodule { In Rust 2015, if you have a submodule: ```rust,ignore -/// foo.rs -/// or -/// foo/mod.rs - +// This `mod` declaration looks for the `foo` module in +// `foo.rs` or `foo/mod.rs`. mod foo; ``` @@ -180,23 +178,43 @@ It can live in `foo.rs` or `foo/mod.rs`. If it has submodules of its own, it *must* be `foo/mod.rs`. So a `bar` submodule of `foo` would live at `foo/bar.rs`. -In Rust 2018, `mod.rs` is no longer needed. - -```rust,ignore -/// foo.rs -/// foo/bar.rs - -mod foo; - -/// in foo.rs -mod bar; -``` - -`foo.rs` can just be `foo.rs`, +In Rust 2018 the restriction that a module with submodules must be named +`mod.rs` is lifted. `foo.rs` can just be `foo.rs`, and the submodule is still `foo/bar.rs`. This eliminates the special name, and if you have a bunch of files open in your editor, you can clearly see their names, instead of having a bunch of tabs named `mod.rs`. + + + + + + + + + + + + + +
Rust 2015Rust 2018
+
+.
+├── lib.rs
+└── foo/
+    ├── mod.rs
+    └── bar.rs
+
+
+
+.
+├── lib.rs
+├── foo.rs
+└── foo/
+    └── bar.rs
+
+
+ ### `use` paths ![Minimum Rust version: 1.32](https://img.shields.io/badge/Minimum%20Rust%20Version-1.32-brightgreen.svg)