Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permit impls to map to private fields #6

Open
nikomatsakis opened this issue May 25, 2017 · 1 comment
Open

permit impls to map to private fields #6

nikomatsakis opened this issue May 25, 2017 · 1 comment

Comments

@nikomatsakis
Copy link
Owner

The current RFC bars mapping public trait members to private fields. @petrochenkov questioned this, and I think rightly so. Basically, there is no major difference between:

impl Foo for Bar {
    f = self.g
}

and

impl Foo for Bar {
    fn f(&self) -> &G { &self.g }
}
@nikomatsakis nikomatsakis changed the title privacy rules around fields in impls permit impls to map to private fields May 25, 2017
@crumblingstatue
Copy link

Allowing private fields is very useful for use in the implementation of provided methods, but it could lead to unintentionally exposing private fields to users, potentially breaking invariants.

I believe this is a strong motivation for Private trait items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants