File tree 1 file changed +18
-3
lines changed 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -29,15 +29,30 @@ mod my_mod {
29
29
}
30
30
31
31
// Functions declared using `pub(in path)` syntax are only visible
32
- // within the given path
32
+ // within the given path. `path` must be a parent or ancestor module
33
33
pub ( in my_mod) fn public_function_in_my_mod ( ) {
34
- println ! ( "called `my_mod::nested::public_function_in_my_mod()`" )
35
- }
34
+ print ! ( "called `my_mod::nested::public_function_in_my_mod()`, that\n > " ) ;
35
+ public_function_in_nested ( )
36
+ }
37
+
38
+ // Functions declared using `pub(self)` syntax are only visible within
39
+ // the current module
40
+ pub ( self ) fn public_function_in_nested ( ) {
41
+ println ! ( "called `my_mod::nested::public_function_in_nested" ) ;
42
+ }
43
+
44
+ // Functions declared using `pub(super)` syntax are only visible within
45
+ // the parent module
46
+ pub ( super ) fn public_function_in_super_mod ( ) {
47
+ println ! ( "called my_mod::nested::public_function_in_super_mod" ) ;
48
+ }
36
49
}
37
50
38
51
pub fn call_public_function_in_my_mod ( ) {
39
52
print ! ( "called `my_mod::call_public_funcion_in_my_mod()`, that\n > " ) ;
40
53
nested:: public_function_in_my_mod ( ) ;
54
+ print ! ( "> " ) ;
55
+ nested:: public_function_in_super_mod ( ) ;
41
56
}
42
57
43
58
// pub(crate) makes functions visible only within the current crate
You can’t perform that action at this time.
0 commit comments