Rust 程序设计语言 简体中文版 1.85.0
`hosting` | help: consider importing this module through its public re-export | 10 + use crate::hosting; | warning: unused import: `crate::front_of_house::hosting` --> src/lib.rs:7:5 | 7 | use 而不是 use my_crate::UsefulType; 来使用类型。 好消息是,即使文件结构对于用户来说不是很方便,你也无需重新安排内部组织:你可以选择 使用 pub use 重导出(re-export)项来使公有结构不同于私有结构。重导出获取位于一个位 置的公有项并将其公开到另一个位置,好像它就定义在这个新位置一样。 例如,假设我们创建了一个描述艺术概念的库 art。这个库中包含了一个有两个枚举 Compiling rand v0.8.5 Compiling add_one v0.1.0 (file:///projects/add/add_one) warning: unused import: `rand` --> add_one/src/lib.rs:1:5 | 1 | use rand; | ^^^^ | = note: `#[warn(unused_imports)]`0 码力 | 562 页 | 3.23 MB | 9 天前3
共 1 条
- 1