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

Add "model" macro to simplify model definitions #625

Merged
merged 1 commit into from
Jan 6, 2020
Merged

Conversation

tjkirch
Copy link
Contributor

@tjkirch tjkirch commented Jan 3, 2020

This removes a lot of repetitive attributes and type modifiers through the use
of a attribute-style procedural macro applied to our model structs.


See the README for the exact changes the macro makes. See the models for how simple they are now :)

Testing done:

I used cargo-expand to compare the generated model package before and after. The only changes were whitespace, ordering of attributes, the new use of model-derive, and the intentional removal of the rustfmt::skip that's no longer needed.

I built and launched an aws-k8s AMI, confirmed all services running, and the API showed all settings. A pod ran OK.

I built and launched an aws-dev AMI, it was running, showed all settings, and a Docker container ran OK.

@tjkirch tjkirch requested review from iliana and zmrow January 3, 2020 23:37
@tjkirch tjkirch force-pushed the model-macro branch 2 times, most recently from 579b187 to 79f750d Compare January 3, 2020 23:39
@tjkirch
Copy link
Contributor Author

tjkirch commented Jan 3, 2020

(The pushes clean up two typos)

workspaces/models/model-derive/src/lib.rs Outdated Show resolved Hide resolved
workspaces/models/model-derive/src/lib.rs Show resolved Hide resolved
This removes a lot of repetitive attributes and type modifiers through the use
of an attribute-style procedural macro applied to our model structs.
@tjkirch
Copy link
Contributor Author

tjkirch commented Jan 6, 2020

This push fixes a typo caught by bcressey.

Copy link
Contributor

@iliana iliana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. Removing the Option<T> in all the types would certainly be confusing if I hadn't seen the #[model] attribute before and I'm trying to write code that uses those fields, but I'm not sure how to resolve that.

@tjkirch tjkirch merged commit 31d515e into develop Jan 6, 2020
@tjkirch tjkirch deleted the model-macro branch January 6, 2020 19:03
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.

3 participants