Use types only

Allowing use to only import types from a module is something that is useful when:

  • you have a platform and want to use it as a short namespace, such as spark::Dialog instead of spark::controls::Dialog;
  • you want to export public items from a certain module of the platform, but not, say, modules or functions, because they might conflict (for example, some modules may share a module of equivalent name support, used for organization only).

An example crate:

#[type_use]
pub use self::foo::*;
#[type_use]
pub use self::qux::*;

If you have two wildcard imports with conflicting names you don't get an error unless you actually try to use the conflicting name. And non-wildcard imports take priority over wildcard imports.

5 Likes

Honestly, I haven't yet encountered the case where WildCard imports where better then implicit imports, exactly because of nameclashes. Can you specify why you need to do that?