4

I'm writing a library, within which I want to use a module types containing Foo, Bar, and Baz. I would like Baz to remain internal to the library, but re-export the other two for using them outside the library. For organizational purposes, I want the exported symbols to live inside the same module, in contrast to re-exporting the individual symbols. In other words, I want to re-export a subset of the module. Is there a neat solution to do this?

I know about pub mod types;, but that re-exports the entire module and since the symbols are pub for usage within the library, this also includes Baz. There is also pub use types::{Foo, Bar};, which only exports the symbols I want, but then they are placed in the library namespace instead of the module.

1
  • 3
    Move types to types_internal then mod types { pub use types_internal::{Foo, Bar} }
    – Shepmaster
    May 18, 2017 at 18:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.