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

Chaining setters? #1

Closed
mdboom opened this issue Jul 6, 2017 · 3 comments
Closed

Chaining setters? #1

mdboom opened this issue Jul 6, 2017 · 3 comments

Comments

@mdboom
Copy link

mdboom commented Jul 6, 2017

Very new to rust, and think this library is really cool.

I wonder if it would be possible to have setters return a reference to self, such that you could chain setters, e.g.:

obj
   .set_foo(2)
   .set_bar(3);
@Hoverbear
Copy link
Collaborator

@Boscop
Copy link
Collaborator

Boscop commented Sep 29, 2018

Btw, I use getset a lot in combination with delegatemethod and have issues with leaked &mut Self access to members which I don't want:
crlf0710/delegatemethod-rs#6

I'd prefer if there was a way to turn off the chainability (returning &mut Self) in the attribute when specifying the setters. Or if chaining wasn't even the default but could be enabled in that attrib with e.g. #[set = "."]/#[set = ".pub"] (I never use chaining anyway).

@Hoverbear
Copy link
Collaborator

@Boscop Hi! That sounds like a very valid feature. How about #[set = "chain pub"]? I would be happy to accept a pr for that!

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

3 participants