This is already possible to emulate in any position other than crate-root:
pub fn foo() { ... }
pub mod foo { ... }
or if you need access to module internals
pub use self::foo::this;
pub mod foo {
pub(crate) fn this() { ... }
pub fn bar();
}
Using the keyword self for this is problematic with what it means in use context, e.g. if the previous example was in the crate baz then
use baz::foo::self;
fn main() {
foo();
}
would not work, self in use context only imports from the module namespace.
Personally I really like this pattern of merged module/value namespaces, I’ve used it in a crate to provide function scoped errors, bs58::decode(foo).into_vec(): Result<_, bs58::decode::DecodeError> (heh, just noticed that even though I’m using this pattern I stuttered when creating it, I should fix that in the next breaking change). If a crate was basically a single function then I would like to make the crate-root itself that function in the value namespace.
Since there is very limited applicability, I wouldn’t see any reason to have a keyword for this. An alternative would be to just have an attribute that can be applied to a single function at the crate-root
#[hoist_to_be_crate_root_in_public_value_namespace]
fn foo() { ... }
But, I’m not sold that it’s useful in enough cases to be worth implementing.