Reputation: 103693
I'd like to import a crate into my library, and then use that crate as if it's a module in my library. If I do this:
extern crate sdl2;
pub use sdl2;
That gives me an error, suggesting I use sdl2::*
, but I don't want to drag all the names from the crate into my library, I want them addressed as a sub-module, for example:
my_library::sdl2::init()
I also tried this:
pub extern crate sdl2;
That compiles, but I have no idea what it does. It doesn't seem to make the crate publicly accessible from my library though.
Upvotes: 1
Views: 724
Reputation: 88536
Another workaround:
extern crate sdl2;
mod sdl2 {
pub use ::sdl2::*;
}
Should work -- untested though.
Upvotes: 0
Reputation: 127741
You can use renaming in use
and extern crate
:
extern crate sdl2 as sdl2_;
pub use sdl2_ as sdl2;
I personally found how to do it in stdx
crate (which appears to be deprecated/abandoned, though, at least for now).
Upvotes: 1