Well... you could consider each member as if it was implemented by accessor method, and control these "methods" even if it was an actual member; of course, also provide a the same syntax for accessing actual members and method-defined-members... but I think this is too far from the current Rust direction.
A friend keyword, on the other hand, should be pretty simple to implement and is a rather minor tweak to the existing system. On Sat, Nov 9, 2013 at 5:50 AM, Gábor Lehel <[email protected]> wrote: > > On Sat, Nov 9, 2013 at 7:43 AM, Oren Ben-Kiki <[email protected]> wrote: > >> 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. >> > > FWIW, I think this might also be partially addressed by my earlier > proposal to remove methods as a distinct concept, and just allow using > dot-syntax with any function? (I have a draft of a follow-up to that thread > that's been sitting there for two weeks... sigh.) > > It wouldn't help with struct members though, which is interesting. Maybe > the import syntax could be extended to accomodate that? > > E.g. > > mod a { pub struct Point { x: int, y: int } } > > mod b { use a::Point; } // currently exists, import all fields > > mod c { use a::Point { * }; } // also import all fields > > mod d { use a::Point { }; } // import no fields > > mod e { use a::Point { x }; } // import only x, not y > > Then you could play similar games with struct fields as with items. > > -- > Your ship was destroyed in a monadic eruption. >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
