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 providedpath
.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 topub(in super)
.pub(self)
makes an item visible to the current module. This is equivalent topub(in self)
or not usingpub
at all.