← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 10645.g · 生成模型:未记录

再导出稳定外部路径

理解等级:高级

pub use 同时让路径在当前模块可用并给外部调用者提供一个公开名字。公开入口因此可以按用户关心的操作来呈现,文件和内部模块可以按实现职责安排。将实现搬到别处时,只要继续保留再导出的公共路径,就能保持调用方式。

相关卡片 [[模块可见性逐段检查]]

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《The Rust Programming Language(第2版)》第07章 用包、crate 和模块管理增长中的项目(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c07.xhtml`,块 0172) - 结论依据:原文将餐厅内部布局和顾客视角分开,说明再导出支持内外两套组织方式。 - 原始内容:Re-exporting is useful when the internal structure of your code is different from how programmers calling your code would think about the domain. For example, in this restaurant metaphor, the people running the restaurant think about “front of house” and “back of house.” But customers visiting a restaurant probably won’t think about the parts of the restaurant in those terms.