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

inherent impls #8

Open
nikomatsakis opened this issue May 25, 2017 · 0 comments
Open

inherent impls #8

nikomatsakis opened this issue May 25, 2017 · 0 comments

Comments

@nikomatsakis
Copy link
Owner

nikomatsakis commented May 25, 2017

The current RFC only describes fields in traits, but -- particularly if we supported shared-only fields (#5) -- it'd be nice to support inherent impls too. Then one could expose a convenient shared-only view of your fields:

pub struct Foo {
   context: Context
}

impl Foo {
    pub let context = self.context; // shared-only view, accessible by anyone
}

Naturally we'd have to work out a few things: priority vis a vis regular fields, for example. In the example above, I'm assuming that we'd use the privacy of the regular field to determine its visibility (as we currently do for autoderef).

Interactions

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

1 participant