Sending an Any across a channel

Playground: Rust Playground

I'm experimenting with sending an Any across a channel. Apparently, Any doesn't require Send, so the spawn of another thread fails. I need to constrain Any to types which are Send, but how do I do that?

(Use case: passing events through a GUI library that doesn't interpret the events it is passing around, but delivers them to something that does, external to the library.)

Use dyn Any + Send. (Trait objects can have any number of + AutoTraits appended.)


Thanks. That's simpler than I expected.
Here it is, working:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.