Ways around the Clone requirement on Message? #1208
-
Using certain widgets (e.g. Button) adds a Clone requirement on Message. As far as I can tell you can only have one Message type for your application, and Messages seem to be the way to pass async data around. This combination can be a little restrictive. Is there some way of structuring my Messages to avoid the clone requirement? Or should I just be sticking everything inside an Arc and not worrying about it? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Removing the Clone bound will end up being more restrictive, since it means Copy types will be copied and non-copyable types will be moved. |
Beta Was this translation helpful? Give feedback.
-
You can decouple the required variants that need to be You can check this out to see what the code for that would look like. |
Beta Was this translation helpful? Give feedback.
-
Thanks for that! I was looking for something like this but hadn’t found
Element::map.
…On Tue, 9 Feb 2021 at 05:56, Eucladia ***@***.***> wrote:
You can decouple the required variants that need to be Clone in your
current Message into another enum that is Clone, use that Message for
your widgets, convert the Widget into an Element with that cloneable
message, then use Element::map to convert the decoupled Message into the
non-clone Message.
You can check this
<#155 (comment)> out to
see what the code for that would look like.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#733 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOYQXKUJDQ44ZIGRVXWOYDS6AJUPANCNFSM4XIHS5HQ>
.
|
Beta Was this translation helpful? Give feedback.
You can decouple the required variants that need to be
Clone
in your currentMessage
into another enum that isClone
, use thatMessage
for your widgets, convert theWidget
into anElement
with that cloneable message, then useElement::map
to convert the cloneableMessage
into the non-cloneMessage
.You can check this out to see what the code for that would look like.