-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Description
Right now, there is no convenient way to define a module like option
, that both defines a type and several accessors. You end up defining a type t
and then writing option::t
, which is unfortunate. So unfortunate, it seems, that we hacked around this particular case in the core library.
Perhaps we could allow a special form of export that lets a module define the other namespaces associated with its name. So, for example, option could be defined as:
export t as mod;
enum t<A> { some(A), none }
fn foo() { ... }
Now if I do import option
, the name option
refers to the module option but also to the type option::t
. You would be permitted one "as mod" export for each namespace other than module (values, types, impls?).
@pcwalton preferred as self
as the syntax, but I don't think self
is currently a keyword, so I substituted mod
.