Merge pull request #1400 from jwcesign/patch-4

doc: 让文件和mod的对应更清晰
main
Sunface 3 weeks ago committed by GitHub
commit 688acd41c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -351,7 +351,16 @@ error[E0583]: file not found for module `front_of_house`
- 在 `front_of_house` 目录里创建一个 `mod.rs`,如果你使用的 `rustc` 版本 `1.30` 之前,这是唯一的方法。 - 在 `front_of_house` 目录里创建一个 `mod.rs`,如果你使用的 `rustc` 版本 `1.30` 之前,这是唯一的方法。
- 在 `front_of_house` **同级**目录里创建一个与模块(目录)**同名**的 rs 文件 `front_of_house.rs`,在新版本里,更建议使用这样的命名方式来避免项目中存在大量同名的 `mod.rs` 文件( Python 点了个 `踩`)。 - 在 `front_of_house` **同级**目录里创建一个与模块(目录)**同名**的 rs 文件 `front_of_house.rs`,在新版本里,更建议使用这样的命名方式来避免项目中存在大量同名的 `mod.rs` 文件( Python 点了个 `踩`)。
而无论是上述哪个方式创建的文件,其内容都是一样的,你需要定义你的子模块(子模块名与文件名相同): 如果使用第二种方式,文件结构将如下所示:
```shell
src
├── front_of_house
│ └── hosting.rs
├── front_of_house.rs
└── lib.rs
```
而无论是上述哪个方式创建的文件,其内容都是一样的,你需要在定义你(`mod.rs` 或 `front_of_house.rs`)的子模块(子模块名与文件名相同):
```rust ```rust
pub mod hosting; pub mod hosting;

Loading…
Cancel
Save