Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
89 lines (56 sloc) 1.58 KB

Modules

Consequences:

1. You don't need to write `mod` anymore.
2. You can tell by looking at an item where it is visible ('>=').

Idea:

1. Every file in your src would be tracked as a module (regardless of mod).
2. An implicit module is as public as its most public member.

pub use self::foo::Bar;

pub fn make_baz() -> self::foo::Baz { }

pub fn make_raz() -> foo::Raz { }

mod foo {
    pub(super) struct Bar;
    pub(super) struct Baz;
    pub(restricted) struct Raz;
}

----

// top of foo.rs
pub mod;
// alternatively:
pub self;

// Equivalent of "pub mod foo" in parent module.

----

struct Private { }
pub use self::Private; // made Private Public

----

FFI-ish facade:

#[cfg(windows)]
#[path = win_foo.rs]
mod foo;

#[cfg(linux)]
#[path = linux_foo.rs]
mod foo;
#[cfg(windows)]
mod win_foo;

#[cfg(windows)]
pub use self::win_foo::*;

#[cfg(linux)]
mod linux_foo;

#[cfg(linux)]
pub use self::linux_foo::*;

How nmatsakis thinks about it: - when you declare pub(X) struct S it means that S is nameable from X at this path - but a pub use within that scope could grow it beyond that

----

Feeling: - this is a big change, would be a hard sell - too many ways to do it - works maybe if we say facading is deprecated - but then supporting portability etc

----

Stack of concerns:

- nmatsakis: pub-in-private is very complex and we don't have consensus on how it should work; how does it fit in here
You can’t perform that action at this time.