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

Suggestion: Enable all attributes (copy-getters, getters, setters) when deriving GetSet #36

Open
Boscop opened this issue Oct 4, 2019 · 3 comments

Comments

@Boscop
Copy link
Collaborator

Boscop commented Oct 4, 2019

Sorry for my long absence, I was very busy..
I'm glad that we now have the way to specify getters that should return by value, but would it be possible to allow the #[get_copy] attribute when only deriving Getters? Not requiring an extra derive (CopyGetters)?

Btw, what was the reason that an extra derive was added for this? I don't think there is any potential for mistakes (like accidentally specifying the wrong kind of getter), and in fact, would it be possible to allow all of getset's attributes just by deriving GetSet?

Sometimes I start out with only deriving Getters and then I add some copy-getter or setter attributes but forget to also derive CopyGetters/Setters and it's one more cargo cycle to notice that..

It would be much more convenient to only have to derive(GetSet), because usually I need getters and setters anyway, and since the goal of this crate is to add convenience & save typing, I think it'd make it even more convenient to enable all attributes at once, what do you think? :)

@Hoverbear
Copy link
Collaborator

Hi @Boscop ! :)

CopyGetters, part of this was because if/when specialization ever lands we won't need it, and also because it was so heavily demanded. Using a distinct type/flag means we have a safe deprecation path.

I think allowing get_copy and get_mut from derive(Getters) is a good idea.

I also think having derive(GetSet) instead of derive(Getters, Setters) is also a good idea. :)

@Hoverbear
Copy link
Collaborator

#49 has made usability considerably improved, is this still a request?

@Boscop
Copy link
Collaborator Author

Boscop commented Jan 29, 2020

@Hoverbear Yes, it would be nice to have this, too. Both of these usability improvements are orthogonal (#49 is about the field attributes, this is about the struct attributes), so they work well together to improve the usability even further :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants