#Export `mod public_prelude` as `prelude` from library?

5 messages · Page 1 of 1 (latest)

red peak
#
//in lib.rs
mod private_prelude; 
mod public_prelude;
pub use public_prelude as prelude;
error[E0365]: `public_prelude` is only public within the crate, and cannot be re-exported outside
 --> src/lib.rs:9:9
  |
9 | pub use public_prelude as prelude;
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^ re-export of crate public `public_prelude`
  |
  = note: consider declaring type or module `public_prelude` with `pub`

is it possible to simultaneously rename and export a module in a library?

ie. make it so that public_prelude is only visible externally as prelude
if I declare public_prelude with pub mod then both public_prelude and prelude will be visible I think

ruby cave
#

I responded here #rust-help-1 message

red peak
#

Why not call public_prelude just prelude - I find I mix up the private and public preludes internally when writing the library. I'd like keep the external api consistent with what other rust libraries do.

The question above is a gap in my knowledge of the language - I feel like I've seen something like this before, but am not sure.

ruby cave
#

Then just use ```rs
pub mod prelude;
use prelude as public_prelude;

#

but you can’t stop yourself from writing crate::prelude anyway