Skip to content

Commit 01ca752

Browse files
authored
Fix and clarify section on re-export
Section on use-visibility fixed to compile under Rust 2018, since they are not absolute paths by default anymore.
1 parent e2f11fe commit 01ca752

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/items/use-declarations.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,26 @@ default. Also like items, a `use` declaration can be public, if qualified by
6060
the `pub` keyword. Such a `use` declaration serves to _re-export_ a name. A
6161
public `use` declaration can therefore _redirect_ some public name to a
6262
different target definition: even a definition with a private canonical path,
63-
inside a different module. If a sequence of such redirections form a cycle or
64-
cannot be resolved unambiguously, they represent a compile-time error.
63+
inside a different module. This allows to present an external interface to a
64+
user of the crate that is different from the internal organization of the code.
65+
If a sequence of such redirections form a cycle or cannot be resolved unambiguously,
66+
they represent a compile-time error.
6567

6668
An example of re-exporting:
6769

6870
```rust
69-
# fn main() { }
7071
mod quux {
71-
pub use quux::foo::{bar, baz};
72-
72+
pub use self::foo::{bar, baz};
7373
pub mod foo {
74-
pub fn bar() { }
75-
pub fn baz() { }
74+
pub fn bar() {}
75+
pub fn baz() {}
7676
}
7777
}
78+
79+
fn main() {
80+
quux::bar();
81+
quux::baz();
82+
}
7883
```
7984

8085
In this example, the module `quux` re-exports two public names defined in

0 commit comments

Comments
 (0)