Skip to content

Commit 8819d3e

Browse files
authored
Merge pull request #2000 from XiaoPengMei/docs/add-pub-use-example-1234
Add a pub use example
2 parents 5383db5 + ceace1a commit 8819d3e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/mod/use.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,24 @@ fn main() {
5353
function();
5454
}
5555
```
56+
57+
You can also use `pub use` to re-export an item from a module, so it can be
58+
accessed through the module's public interface:
59+
60+
```rust,editable
61+
mod deeply {
62+
pub mod nested {
63+
pub fn function() {
64+
println!("called `deeply::nested::function()`");
65+
}
66+
}
67+
}
68+
69+
mod cool {
70+
pub use crate::deeply::nested::function;
71+
}
72+
73+
fn main() {
74+
cool::function();
75+
}
76+
```

0 commit comments

Comments
 (0)