@@ -64,28 +64,22 @@ A module without a body is loaded from an external file. When the module does
64
64
not have a ` path ` attribute, the path to the file mirrors the logical [ module
65
65
path] .
66
66
67
- r[ items.mod.outlined.search]
68
- Ancestor module path components are directories, and the module's
69
- contents are in a file with the name of the module plus the ` .rs ` extension.
67
+ r[ items.mod.outlined.search] Ancestor module path components are directories, and the module's
68
+ contents are in a file with the name of the module plus the ` .rs ` extension. Alternatively, the
69
+ module's contents can also be in a file called ` mod.rs ` in a directory with the name of the module.
70
+ It is not allowed to have both ` $name.rs ` and ` $name/mod.rs ` .
71
+
70
72
For example, the following module structure can have this corresponding
71
73
filesystem structure:
72
74
73
75
Module Path | Filesystem Path | File Contents
74
76
------------------------- | --------------- | -------------
75
77
` crate ` | ` lib.rs ` | ` mod util; `
76
- ` crate::util ` | ` util.rs ` | ` mod config; `
78
+ ` crate::util ` | ` util.rs ` * or * ` util/mod.rs ` | ` mod config; `
77
79
` crate::util::config ` | ` util/config.rs ` |
78
80
79
- r[ items.mod.outlined.search-mod]
80
- Module filenames may also be the name of the module as a directory with the
81
- contents in a file named ` mod.rs ` within that directory. The above example can
82
- alternately be expressed with ` crate::util ` 's contents in a file named
83
- ` util/mod.rs ` . It is not allowed to have both ` util.rs ` and ` util/mod.rs ` .
84
-
85
81
> ** Note** : Prior to ` rustc ` 1.30, using ` mod.rs ` files was the way to load
86
- > a module with nested children. It is encouraged to use the new naming
87
- > convention as it is more consistent, and avoids having many files named
88
- > ` mod.rs ` within a project.
82
+ > a module with nested children.
89
83
90
84
### The ` path ` attribute
91
85
0 commit comments