From ceace1aaca17f637656a3ef01f50a7f445604661 Mon Sep 17 00:00:00 2001 From: DavidMei <94948521@163.com> Date: Fri, 27 Mar 2026 20:44:07 +0800 Subject: [PATCH] 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 --- src/mod/use.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/mod/use.md b/src/mod/use.md index 7a57272b15..6d7ccfaf17 100644 --- a/src/mod/use.md +++ b/src/mod/use.md @@ -53,3 +53,24 @@ fn main() { function(); } ``` + +You can also use `pub use` to re-export an item from a module, so it can be +accessed through the module's public interface: + +```rust,editable +mod deeply { + pub mod nested { + pub fn function() { + println!("called `deeply::nested::function()`"); + } + } +} + +mod cool { + pub use crate::deeply::nested::function; +} + +fn main() { + cool::function(); +} +```