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

Feature/skip setter #44

Merged
merged 3 commits into from
Feb 20, 2017
Merged

Feature/skip setter #44

merged 3 commits into from
Feb 20, 2017

Conversation

colin-kiegel
Copy link
Owner

@colin-kiegel colin-kiegel commented Feb 19, 2017

  • skip setters, e.g. #[builder(setter(skip))]
    idea: hidden fields #15
  • deprecated syntax #[builder(setter_prefix="with")],
    please use #[builder(setter(prefix="with"))] instead
  • Custom derives can't emit nice warnings to the user??
    Hah! Have a look at this and this! :-)

- skip setters, e.g. `#[builder(setter(skip))]`
  #15

- deprecated syntax `#[builder(setter_prefix="with")]`,
  please use `#[builder(setter(prefix="with"))]` instead
@colin-kiegel
Copy link
Owner Author

colin-kiegel commented Feb 19, 2017

I'm not really sure that I want to deprecate #[builder(setter_prefix="with")] in favour of #[builder(setter(prefix="with"))]. But it was a good testcase for my idea to model deprecation notes.

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.

Copy link
Collaborator

@killercup killercup left a 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
Copy link
Collaborator

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: 😄

Copy link
Owner Author

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
Copy link
Collaborator

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]
Copy link
Collaborator

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

@colin-kiegel
Copy link
Owner Author

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. :-)

@colin-kiegel colin-kiegel merged commit 32a6437 into master Feb 20, 2017
@colin-kiegel colin-kiegel deleted the feature/skip_setter branch February 20, 2017 20:12
@colin-kiegel colin-kiegel mentioned this pull request Apr 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants