Many thanks for the replies.

My problem is actually in accessing private methods/members of a struct
defined in a different, but "very closely related" module. It seems @
nikomatsakis <https://github.com/nikomatsakis> is saying in the final text
comment of https://github.com/mozilla/rust/issues/8215 that it is not
possible to specify methods/members that are only accessible from within a
small set of modules; they are either completely public, or private to a
single module.

Looking at the same thread, I see nobody asked about a possibility of
keeping the existing rules, but also adding a "friend" keyword at the
module level; that is, if a module foo says "friend mod bar", then the
module bar can access any private stuff in the module foo. I'm not very
enamored of the friend keyword in C++, but it seems to me that having it
only in module level greatly simplifies things. Also, in a Rust context, it
seems it would cut down on much of the boilerplate code needed by barrier
modules (which is not to say that re-exporting isn't a very useful feature
as of itself).

I don't want to re-open old discussions - is this something that was
considered and rejected before?
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to