Skip to content

Commit cbdf707

Browse files
authored
Merge pull request #107 from ZhangHanDong/patch-1
Clearer documentation for "No more mod.rs"
2 parents 70bf8ac + 9f3863d commit cbdf707

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/rust-2018/module-system/path-clarity.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,30 @@ Much more straightforward.
212212
In Rust 2015, if you have a submodule:
213213

214214
```rust,ignore
215+
/// foo.rs
216+
/// or
217+
/// foo/mod.rs
218+
215219
mod foo;
216220
```
217221

218222
It can live in `foo.rs` or `foo/mod.rs`. If it has submodules of its own, it
219223
*must* be `foo/mod.rs`. So a `bar` submodule of `foo` would live at
220224
`foo/bar.rs`.
221225

222-
In Rust 2018, `mod.rs` is no longer needed. `foo.rs` can just be `foo.rs`,
226+
In Rust 2018, `mod.rs` is no longer needed.
227+
228+
```rust,ignore
229+
/// foo.rs
230+
/// foo/bar.rs
231+
232+
mod foo;
233+
234+
/// in foo.rs
235+
mod bar;
236+
```
237+
238+
`foo.rs` can just be `foo.rs`,
223239
and the submodule is still `foo/bar.rs`. This eliminates the special
224240
name, and if you have a bunch of files open in your editor, you can clearly
225241
see their names, instead of having a bunch of tabs named `mod.rs`.

0 commit comments

Comments
 (0)