Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Ways around the Clone requirement on Message? #733

Closed
anderslanglands opened this issue Feb 8, 2021 · 3 comments
Closed

Ways around the Clone requirement on Message? #733

anderslanglands opened this issue Feb 8, 2021 · 3 comments
Labels
question Further information is requested
Milestone

Comments

@anderslanglands
Copy link

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?

@MoAlyousef
Copy link

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.

@Eucladia
Copy link

Eucladia commented Feb 8, 2021

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 cloneable Message into the non-clone Message.

You can check this out to see what the code for that would look like.

@anderslanglands
Copy link
Author

anderslanglands commented Feb 8, 2021 via email

@hecrj hecrj added the question Further information is requested label Feb 12, 2021
@hecrj hecrj added this to the 0.3.0 milestone Feb 12, 2021
@hecrj hecrj modified the milestones: 0.3.0, 0.4.0 Mar 31, 2021
@hecrj hecrj closed this as completed Jan 20, 2022
@iced-rs iced-rs locked and limited conversation to collaborators Jan 20, 2022
@hecrj hecrj converted this issue into discussion #1208 Jan 20, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants