File tree Expand file tree Collapse file tree 1 file changed +35
-17
lines changed
src/rust-2018/module-system Expand file tree Collapse file tree 1 file changed +35
-17
lines changed Original file line number Diff line number Diff line change @@ -169,34 +169,52 @@ mod submodule {
169169In Rust 2015, if you have a submodule:
170170
171171``` rust,ignore
172- /// foo.rs
173- /// or
174- /// foo/mod.rs
175-
172+ // This `mod` declaration looks for the `foo` module in
173+ // `foo.rs` or `foo/mod.rs`.
176174mod foo;
177175```
178176
179177It can live in ` foo.rs ` or ` foo/mod.rs ` . If it has submodules of its own, it
180178* must* be ` foo/mod.rs ` . So a ` bar ` submodule of ` foo ` would live at
181179` foo/bar.rs ` .
182180
183- In Rust 2018, ` mod.rs ` is no longer needed.
184-
185- ``` rust,ignore
186- /// foo.rs
187- /// foo/bar.rs
188-
189- mod foo;
190-
191- /// in foo.rs
192- mod bar;
193- ```
194-
195- ` foo.rs ` can just be ` foo.rs ` ,
181+ In Rust 2018 the restriction that a module with submodules must be named
182+ ` mod.rs ` is lifted. ` foo.rs ` can just be ` foo.rs ` ,
196183and the submodule is still ` foo/bar.rs ` . This eliminates the special
197184name, and if you have a bunch of files open in your editor, you can clearly
198185see their names, instead of having a bunch of tabs named ` mod.rs ` .
199186
187+ <table >
188+ <thead >
189+ <tr>
190+ <th>Rust 2015</th>
191+ <th>Rust 2018</th>
192+ </tr>
193+ </thead >
194+ <tbody >
195+ <tr>
196+ <td>
197+ <pre >
198+ .
199+ ├── lib.rs
200+ └── foo/
201+ ├── mod.rs
202+ └── bar.rs
203+ </pre >
204+ </td>
205+ <td>
206+ <pre >
207+ .
208+ ├── lib.rs
209+ ├── foo.rs
210+ └── foo/
211+ └── bar.rs
212+ </pre >
213+ </td>
214+ </tr>
215+ </tbody >
216+ </table >
217+
200218### ` use ` paths
201219
202220![ Minimum Rust version: 1.32] ( https://img.shields.io/badge/Minimum%20Rust%20Version-1.32-brightgreen.svg )
You can’t perform that action at this time.
0 commit comments