From 6d9cc38204a078076aff43d9e1fc5335d1caeb28 Mon Sep 17 00:00:00 2001 From: 3D Pinball <3dpinball1834497651@gmail.com> Date: Tue, 6 Jan 2026 22:21:14 +0800 Subject: [PATCH] Fix: Typo in module.md --- src/basic/crate-module/module.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basic/crate-module/module.md b/src/basic/crate-module/module.md index 0c44ad83..64c28377 100644 --- a/src/basic/crate-module/module.md +++ b/src/basic/crate-module/module.md @@ -127,7 +127,7 @@ front_of_house::hosting::add_to_waitlist(); 如果只是为了引用到指定模块中的对象,那么两种都可以,但是在实际使用时,需要遵循一个原则:**当代码被挪动位置时,尽量减少引用路径的修改**,相信大家都遇到过,修改了某处代码,导致所有路径都要挨个替换,这显然不是好的路径选择。 -回到之前的例子,如果我们把 `front_of_house` 模块和 `eat_at_restaurant` 移动到一个模块中 `customer_experience`,那么绝对路径的引用方式就必须进行修改:`crate::customer_experience::front_of_house ...`,但是假设我们使用的相对路径,那么该路径就无需修改,因为它们两个的相对位置其实没有变: +回到之前的例子,如果我们把 `front_of_house` 模块和 `eat_at_restaurant` 移动到一个模块中 `customer_experience`,那么绝对路径的引用方式就必须进行修改:`crate::customer_experience::front_of_house ...`,但是假设我们使用的是相对路径,那么该路径就无需修改,因为它们两个的相对位置其实没有变: ```console crate @@ -346,7 +346,7 @@ error[E0583]: file not found for module `front_of_house` = help: to create the module `front_of_house`, create file "src/front_of_house.rs" or "src/front_of_house/mod.rs" ``` -是的,如果需要将文件夹作为一个模块,我们需要进行显示指定暴露哪些子模块。按照上述的报错信息,我们有两种方法: +是的,如果需要将文件夹作为一个模块,我们需要进行显式指定暴露哪些子模块。按照上述的报错信息,我们有两种方法: - 在 `front_of_house` 目录里创建一个 `mod.rs`,如果你使用的 `rustc` 版本 `1.30` 之前,这是唯一的方法。 - 在 `front_of_house` **同级**目录里创建一个与模块(目录)**同名**的 rs 文件 `front_of_house.rs`,在新版本里,更建议使用这样的命名方式来避免项目中存在大量同名的 `mod.rs` 文件( Python 点了个 `踩`)。