05.3 pub use re-exports
Building a stable public API surface without dumping every internal module."
pub use re-exports
pub use is how you tell the truth about your package API without inviting every consumer into internal/v2/experimental/.
Pattern
Section titled “Pattern”Boundary module at myapp.api:
mod myapp.api;
pub use myapp.core.Service;pub use myapp.core.Config;// do NOT pub use myapp.core.HelperHack;Consumers import from myapp.api, not from twenty leaf modules.
When re-exports help
Section titled “When re-exports help”- You split implementation across files but want one import path for apps
- You rename internal modules without breaking callers (re-export old names temporarily)
- You mirror platform-spec “feature hub” style surfaces in libraries
When re-exports hurt
Section titled “When re-exports hurt”- Re-exporting everything
pubin core because you were lazy - Accidentally
pub useinternal helpers—now they are semver
flowchart LR INT[internal modules] --> API[api.bd pub use] API --> APP[application imports]
Relation to project root_namespace
Section titled “Relation to project root_namespace”root_namespace in Project.proj is metadata for package naming conventions—it does not replace module paths in source. Keep module declarations honest.