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

How to do ref mut args? #2

Closed
Boscop opened this issue Jul 28, 2018 · 1 comment
Closed

How to do ref mut args? #2

Boscop opened this issue Jul 28, 2018 · 1 comment

Comments

@Boscop
Copy link

Boscop commented Jul 28, 2018

How can I mark an arg as ref mut?

defmac!(send ref mut slf, msg => { let m = msg; slf.send(m); });

I get this error:

image

when trying to call this macro with self as first arg in a method that gets self as &mut.

E.g. send!(self, Msg::Search(self.search_input.clone()));

@bluss
Copy link
Owner

bluss commented Jul 28, 2018

There seems to be multiple things going on there, there is no problem with using ref mut in general with the macro. In your case you want to borrow self mutably more than once I think? Because self is the first argument to send! you will get something that's equivalent to match self { slf => { ... } } which borrows self mutably for the whole expression.

@bluss bluss closed this as completed Nov 19, 2018
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

No branches or pull requests

2 participants