-
Notifications
You must be signed in to change notification settings - Fork 84
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
Feature/skip setter #44
Conversation
- skip setters, e.g. `#[builder(setter(skip))]` #15 - deprecated syntax `#[builder(setter_prefix="with")]`, please use `#[builder(setter(prefix="with"))]` instead
I'm not really sure that I want to deprecate Feel free to criticise anything you don't like. My current tendency is to accumulate a few features in the master branch before rolling out the next release. This way we can iterate a little over our API and see how it plays together first. Next in line would be no_std (#41), optional setters (#36) and CustomDefaults (#3) IMO. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Emitting depreciation warnings is a cool idea. Fwiw, I like the new setter attribute.
In other news, have you seen https://github.com/Nemo157/prom-attire-rs/? (I haven't used it myself)
//! You can hide fields by skipping their setters on the builder struct. | ||
//! | ||
//! - Opt-out — skip setters via `#[builder(setter(skip))]` on individual fields. | ||
//! - Opt-in — set `#[builder(setter(skip))]` on the whole struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does rustdoc actually render —
as HTML entity? Freaky. If not, here, haven an m-dash: —
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, —
works in rustdoc - afaik it's a feature of markdown in general. :-)
|
||
/// This will emit a block which can be inserted into any fn body to emit a | ||
/// deprecation warning in the downstream crate. Cool stuff. ^^ | ||
/// Proof of concept: https://play.rust-lang.org/?gist=8394141c07d1f6d75d314818389eb4d8&version=stable&backtrace=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is brilliant :O
fn parse_builder_options_list( | ||
&mut self, | ||
ident: &syn::Ident, | ||
nested: &[syn::NestedMetaItem] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, you can use trailing commas in param lists to prevent needless diff churn in the future
I have heard of prom-attire but it's currently not documented at all and not even published on crates.io... That's basically all I know right now. :-) |
#[builder(setter(skip))]
idea: hidden fields #15
#[builder(setter_prefix="with")]
,please use
#[builder(setter(prefix="with"))]
insteadHah! Have a look at this and this! :-)