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

Added setters to structs #52

Merged
merged 6 commits into from
Jul 12, 2017
Merged

Added setters to structs #52

merged 6 commits into from
Jul 12, 2017

Conversation

jameshurst
Copy link
Member

@jameshurst jameshurst commented Jul 7, 2017

Revisiting #41, I've added setters to all the structs, replacing the shim I had put in earlier to create builders from existing structs.

Examples have been revised to be more succinct.

The builders are now automatically created using derive_builder crate which should help keep builder methods and struct properties consistent.

These changes bring the code more in line with the patterns that I used in the atom_syndication crate as well which should make understanding one library easier if you've already used the other.

Additionally I've also moved validation out to its own module and made it an optional dependency to try and keep the core crate focused on just reading and writing.

@frewsxcv
Copy link
Member

frewsxcv commented Jul 8, 2017

How difficult would it be to separate the 'setters' changes and the 'validation' changes? If it's easy, is it cool to put them in separate (maybe subsequent) PRs?

@jameshurst
Copy link
Member Author

jameshurst commented Jul 8, 2017

Since all the validation methods were previously part of the builder structs I had to remove them when switching to the derived builders. So it probably wouldn't be all that simple to have split out those changes.

Copy link
Member

@frewsxcv frewsxcv left a comment

Choose a reason for hiding this comment

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

Seems unfortunate that we lose the specialized doc comments/examples for the builders, and I also find it a little weird that all the methods of the builders use Into<T>, not sure why they do that. In any case, if this is something people want, then sure, works for me

@jameshurst
Copy link
Member Author

jameshurst commented Jul 12, 2017

The derived builders have the option to not take Into<T> but the advantage of using Into<T> instead of T is you can pass T to a setter that would normally take an Option<T> or an &str to a setter that would take a String which makes the API a bit nicer to use.

@jameshurst jameshurst merged commit 96dbdf8 into master Jul 12, 2017
@jameshurst jameshurst deleted the setters branch July 12, 2017 18:34
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.

None yet

2 participants