]>
Commit | Line | Data |
---|---|---|
3dfed10e | 1 | An incorrect visibility restriction was specified. |
60c5eb7d | 2 | |
3dfed10e | 3 | Erroneous code example: |
60c5eb7d XL |
4 | |
5 | ```compile_fail,E0704 | |
6 | mod foo { | |
7 | pub(foo) struct Bar { | |
8 | x: i32 | |
9 | } | |
10 | } | |
11 | ``` | |
12 | ||
13 | To make struct `Bar` only visible in module `foo` the `in` keyword should be | |
14 | used: | |
3dfed10e | 15 | |
60c5eb7d XL |
16 | ``` |
17 | mod foo { | |
18 | pub(in crate::foo) struct Bar { | |
19 | x: i32 | |
20 | } | |
21 | } | |
22 | # fn main() {} | |
23 | ``` | |
24 | ||
25 | For more information see the Rust Reference on [Visibility]. | |
26 | ||
27 | [Visibility]: https://doc.rust-lang.org/reference/visibility-and-privacy.html |