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

Allow adding independent values to a Vec/HashMap etc. #26

Open
WhiteHatTux opened this issue Feb 18, 2023 · 1 comment
Open

Allow adding independent values to a Vec/HashMap etc. #26

WhiteHatTux opened this issue Feb 18, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@WhiteHatTux
Copy link

WhiteHatTux commented Feb 18, 2023

Given a struct like this:

#[derive(Debug, Builder)]
pub struct QueryParameters {
    pub table_name: String,
    #[default(Option::None)]
    pub index_name: Option<String>,
    #[default(Option::None)]
    pub key_condition_expression: Option<String>,
    pub expression_attribute_values: Vec<(String, AttributeValue)>,
}

I would like to generate like this:

QueryParameters::new()
.table_name("table")
.add_expression_attribute_values(("string".to_string(), AttributeValue::S("attribute")))
.add_expression_attribute_values(("secondString".to_string(), AttributeValue::S("second attribute")))
.build();

So when calling "new" the expression_attribute_values are initialized, and then I can call the builder method however many times I want and it will add to the existing Vec.

The same could also be applied to HashMap and other iterables.
Similar to what lombok provides for java devs:
https://projectlombok.org/features/Builder#singular

I checked the documentation but couldn't find a way to do this with the current version of the library.

@SeokminHong
Copy link
Owner

Thanks for making the issue! I'll work on it soon.

@SeokminHong SeokminHong self-assigned this Feb 21, 2023
@SeokminHong SeokminHong added the enhancement New feature or request label Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants