[rust-dev] Library organization

Brian Anderson banderson at mozilla.com
Mon Jul 2 11:59:59 PDT 2012


On 07/01/2012 03:47 PM, Jesse Jones wrote:
> I'm confused about how I can structure libraries. Let's say I have a whizbang library. It's complex enough that I want whiz and bang submodules, but that's just an implementation detail: I'd like clients of the libraries to use the public API with just an `import whizbang;`. I had thought something like the following would work:
>
> whizbang.rs
>     import whiz::*;
>     import bang::*;
>
>     export whiz1, whiz2;
>     export bang1;
>
> whiz.rs:
>     fn whiz1() {}
>     fn whiz2() {}
>
> bang.rs:
>     fn bang1() {}
>
> And it does work…but only within the whizbang project. whiz.rs, for example, can use bang1 without even doing an import. But external libraries have to do whizbang::whiz::whiz1.
>

I would expect this to work as written. core.rs does similar things to 
expose option::some, none, etc. Perhaps it's because of a resolve bug. 
core doesn't use `import::*` for example, so maybe reexporting an import 
star is funky.



More information about the Rust-dev mailing list