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

Have From{Derive,Variant}::from_ident not Option. #29

Merged
merged 1 commit into from
May 16, 2018

Conversation

upsuper
Copy link
Contributor

@upsuper upsuper commented Apr 28, 2018

From{Derive,Variant} only have one place each initializes them, and both places use Some on from_ident, so it seems unnecessary to use Option<bool> on them.

`From{Derive,Variant}` only have one place each initializes them, and
both places use `Some` on `from_ident`, so it seems unnecessary to use
`Option<bool>` on them.
@TedDriggs
Copy link
Owner

This is actually deliberate; it allows us to separate out the omission case from the explicit false case. This was something I learned to do working on derive_builder, and I feel pretty strongly about maintaining fidelity about user input for as long as possible.

@TedDriggs TedDriggs closed this Apr 30, 2018
@TedDriggs TedDriggs mentioned this pull request May 1, 2018
@upsuper
Copy link
Contributor Author

upsuper commented May 2, 2018

I don't really get the point. As can be seen from the change, there is no place initializing those fields to None at all, so you are not really maintaining anything, given that the value is always Some(something).

@TedDriggs
Copy link
Owner

Hmmm, I’ll take a look. I may have made a mistake in my code.

@upsuper
Copy link
Contributor Author

upsuper commented May 2, 2018

Actually, is it really possible for people to declare false for that? It seems to me that having from_ident listed means it's true, not having it means false. Is there a third state at all?

@TedDriggs
Copy link
Owner

@upsuper I missed your last comment on this. I'm probably being overly-cautious here, but when I was working on rust-derive-builder (which does a lot of struct --> field inheritance) that being diligent about tracking the three states separately made supporting opt-in and opt-out scenarios easier. In this case, I think you're right though: There's no notion of inheritance for either of those.

@TedDriggs TedDriggs reopened this May 16, 2018
@TedDriggs TedDriggs merged commit cea3b57 into TedDriggs:master May 16, 2018
@upsuper upsuper deleted the from_ident branch May 16, 2018 22:12
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