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

Consider new public/private declaration format to account for restricted visibility #96

Closed
TedDriggs opened this issue May 5, 2017 · 4 comments

Comments

@TedDriggs
Copy link
Collaborator

With restricted visibility stabilizing in 1.18 (see rust-lang/rust#32409), it would be good for derive_builder to support declaring restricted visibility for the generated structs, setters, and fields.

Proposal

#[derive(Builder)]
#[builder(vis = "pub(crate)")]
pub(crate) struct Foo {
    bar: u8
}

This would also be available in the setter, field, and build_fn sub-options. We could keep the current #[builder(public)] option for compatibility, but I think it probably makes sense to deprecate it since the method above is more future-proof (and easier to validate that it only appears once).

@colin-kiegel
Copy link
Owner

Sounds reasonable

  • What would be the new expression for #[builder(setter(private))]? This is needed for overrides. Would it be vis="" or vis="priv"? Both don't look particularly good IMO.

@colin-kiegel
Copy link
Owner

Alternatively we could introduce #[builder(pub(crate)] or #[builder(public(crate)]...

@TedDriggs
Copy link
Collaborator Author

I tried #[builder(pub(crate))], but that doesn't seem to work because the format uses pub(in mod), which won't get passed by syn as a valid meta-item. The private thing is interesting; don't have a good answer there.

@TedDriggs
Copy link
Collaborator Author

We haven't heard any requests for this; closing it.

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