January 2019
Beginner to intermediate
554 pages
13h 31m
English
The privacy of items in Rust starts at the module level. As a library author, to expose things to users from a module, we use the pub keyword. But there are items that we only want to expose to other modules within the crate, but not to the users. In such cases, we can use the pub(crate) modifier for the item, which allows the item to be exposed only within the crate.
Consider the following code:
// pub_crate.rsfn main() { }
Read now
Unlock full access