module-concept

Rust Public re-exports

Offer a stable public entry point while allowing the implementation to stay in a private module. The re-export creates another reachable path to the same eligible item rather than copying its definition. Expected result (not executed): 14 Why: The root exports Receipt under a shorter public path. Common mistake: Assuming pub use can expose an item whose own visibility forbids it.

Formal Syntax & Structure

rust syntaxrust
pub use internal::Item;

Working Example

Example Snippetrust
mod internal { pub struct Receipt { pub total: u32 } }pub use internal::Receipt;fn main() { let r = Receipt { total: 14 }; println!("{}", r.total); }
Rust Reference