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
Compilation error when using non-Copy types in messages #303
Comments
You have to add See this example. |
Is there a reason why you force the |
I'm not sure exactly where Both the current widget and parent widgets can see the same message. The current widget gets an owned version of the event, but to avoid a clone, the parent widgets get a reference. |
I'm talking about this one: https://docs.rs/relm/0.24.0/src/relm/macros.rs.html#113. It is the source for the As far as I understand it, the parameter passed by |
Oh, that's because of match ergonomics: the Rust compiler automatically adds the I find this leads to worse error messages which is why I prefer to avoid it. |
Well, it doesn't add the There might be other cases where this isn't the case that I just haven't found yet of course. |
Indeed, Rust won't do match ergonomics if you add |
Whenever I have a message type that is non-Copy, e.g.
Then I cannot use this message, or otherwise I get a compilation error:
The error message is
This is impossible to fix in user code, using e.g.
Msg::MyEvent(foo.clone())
orMsg::MyEvent((&*foo).into())
produces the exact same error message. The problem is within the macro-generated code that produces&MyWidgetMyEvent(foo)
. I believe this could be fixed by emiting&MyWidgetMyEvent(ref foo)
, but I haven't tested that.The text was updated successfully, but these errors were encountered: