On 07/30/2013 08:10 AM, Corey Richardson wrote:
On Tue, Jul 30, 2013 at 8:09 AM, Dov Reshef <[email protected]> wrote:
Hello,

I'd like to get people's opinions about crate local visibility. I feel that
the way the public / private scope is divided now is encouraging making
either too much code public or creating very large modules.

I agree! It's very count-intuitive that to access sibling modules they
need to be exposed to the whole world.

I don't think that's the case. I submitted a bug that concerns this: https://github.com/mozilla/rust/issues/7388 . I note, however, that now that code gives you a linker error (which is better than nothing). To reduce the example a bit:

// This is a crate-local module, inaccessible from the outside of the crate
mod private
{
        pub fn private_fun()
        {
                
        }
}

// This is a public module, accessible from the outside of the crate
pub mod public
{
        use super::private::*;
        pub fn public_fun()
        {
                private_fun();
        }
}

I'm not sure that's how it is supposed to be, but I'd prefer it to be by design. Incidentally, accessing that private_fun() from outside the crate gives you a linker error today.

-SL
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to