IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Rust visibility

    金庆发表于 2021-08-09 05:45:00
    love 0
    From: Visibility and privacy - The Rust Reference (rust-lang.org)

    pub(in path), pub(crate), pub(super), and pub(self)

    In addition to public and private, Rust allows users to declare an item as visible only within a given scope. The rules for pub restrictions are as follows:

    • pub(in path) makes an item visible within the provided path. path must be an ancestor module of the item whose visibility is being declared.
    • pub(crate) makes an item visible within the current crate.
    • pub(super) makes an item visible to the parent module. This is equivalent to pub(in super).
    • pub(self) makes an item visible to the current module. This is equivalent to pub(in self) or not using pub at all.


    金庆 2021-08-09 13:45 发表评论


沪ICP备19023445号-2号
友情链接