Skip to content

Update pub(in path) for 2018. #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/visibility-and-privacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,19 @@ be a parent module of the item whose visibility is being declared.
- `pub(self)` makes an item visible to the current module. This is equivalent
to `pub(in self)`.

> **Edition Differences**: Starting with the 2018 edition, paths for
> `pub(in path)` must start with `crate`, `self`, or `super`. The 2015 edition
> may also use paths starting with `::` or modules from the crate root.

Here's an example:

```rust
pub mod outer_mod {
pub mod inner_mod {
// This function is visible within `outer_mod`
pub(in outer_mod) fn outer_mod_visible_fn() {}
pub(in crate::outer_mod) fn outer_mod_visible_fn() {}
// Same as above, this is only valid in the 2015 edition.
pub(in outer_mod) fn outer_mod_visible_fn_2015() {}

// This function is visible to the entire crate
pub(crate) fn crate_visible_fn() {}
Expand Down