@@ -65,27 +65,22 @@ not have a `path` attribute, the path to the file mirrors the logical [module
65
65
path] .
66
66
67
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.
68
+ Ancestor module path components are directories, and the module's contents are in a file with the
69
+ name of the module plus the ` .rs ` extension. Alternatively, the module's contents can also be in a
70
+ file called ` mod.rs ` in a directory with the name of the module. It is not allowed to have both
71
+ ` $name.rs ` and ` $name/mod.rs ` .
72
+
70
73
For example, the following module structure can have this corresponding
71
74
filesystem structure:
72
75
73
76
Module Path | Filesystem Path | File Contents
74
77
------------------------- | --------------- | -------------
75
78
` crate ` | ` lib.rs ` | ` mod util; `
76
- ` crate::util ` | ` util.rs ` | ` mod config; `
79
+ ` crate::util ` | ` util.rs ` * or * ` util/mod.rs ` | ` mod config; `
77
80
` crate::util::config ` | ` util/config.rs ` |
78
81
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
82
> ** 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.
83
+ > a module with nested children.
89
84
90
85
### The ` path ` attribute
91
86
0 commit comments