trpl-zh-cn
trpl-zh-cn copied to clipboard
疑似错误
https://kaisery.github.io/trpl-zh-cn/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html
mod front_of_house {
pub mod hosting {
pub fn add_to_waitlist() {}
}
}
use crate::front_of_house::hosting;
mod customer {
pub fn eat_at_restaurant() {
hosting::add_to_waitlist();
}
}
注意这里还有一个警告说 use 在其作用域内不再被使用!为了修复这个问题,可以将 use 移动到 customer 模块内,或者在子模块 customer 内通过 super::hosting
引用父模块中的这个短路径。
super::hosting
应该是 super::front_of_house::hosting