Hacker News new | past | comments | ask | show | jobs | submit login

The main issue with Rust's module system is that your own modules and crates live in the same namespace. So if you have a `mylib/image.rs` file and you want to use the image crate then you can't without either renaming your `image.rs` or you alias the crate on import.

I really wish your own modules would require some relative import and be scoped within `mylib`. Eg you would do `use mylib::image::MyImage` and `use image::OtherImage` instead of `extern crate image as image_crate; use image::MyImage; use image_crate::OtherImage`.

So Rust essentially has the same design issue that Python had before PEP 328?

Not exactly; Python had the problem where `import foo` had two different meanings and there was no way of working around it. Rust still understands that crates are different, and will let you do `extern crate foo as bar` to avoid conflicts.

Correct me if I'm wrong, but I think the proposed implicit modules in the article would fix this issue. Instead of exposing mylib/image.rs via mod, you'd just import it as an 'implicit' module.

So you'd end up with `use image::MyImage` and `use self::MyImage`?

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact