Skip to content

Commit ceace1a

Browse files
Add a pub use example
Show how a module can re-export an item with pub use so the use declaration chapter covers that common pattern directly. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent 5383db5 commit ceace1a

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)