Skip to content

Commit 2a487bd

Browse files
Merge pull request #480 from ehuss/pub-in-path-2018
Update pub(in path) for 2018.
2 parents e57b2ee + 422bcd7 commit 2a487bd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/visibility-and-privacy.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,19 @@ be a parent module of the item whose visibility is being declared.
154154
- `pub(self)` makes an item visible to the current module. This is equivalent
155155
to `pub(in self)`.
156156

157+
> **Edition Differences**: Starting with the 2018 edition, paths for
158+
> `pub(in path)` must start with `crate`, `self`, or `super`. The 2015 edition
159+
> may also use paths starting with `::` or modules from the crate root.
160+
157161
Here's an example:
158162

159163
```rust
160164
pub mod outer_mod {
161165
pub mod inner_mod {
162166
// This function is visible within `outer_mod`
163-
pub(in outer_mod) fn outer_mod_visible_fn() {}
167+
pub(in crate::outer_mod) fn outer_mod_visible_fn() {}
168+
// Same as above, this is only valid in the 2015 edition.
169+
pub(in outer_mod) fn outer_mod_visible_fn_2015() {}
164170

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

0 commit comments

Comments
 (0)