-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
"Clone" kind bound on closures and traits, with autogenerated clone implementation #2830
Comments
Hopefully we can do this with the visitor interface. We start by adding a |
This bit me when I updated a library to use pipes. I was relying on being able to copy channels which works with oldcomms but not with pipes::SharedChan. I haven't been able to come up with a good work around (other than dropping pipes). Closest I was able to find is to use MutexARC but that's A) clumsy and B) needs tweaks to the API (see #4292). Here is an example of the sort of thing I was trying to do:
|
@jesse99 SharedChan should have a clone() method too. |
|
We've discussed the possibility of having a |
Nominating production-ready milestone, I guess? This wouldn't be a backwards-compatibility hazard or anything. |
just a bug, removing milestone/nomination. |
|
@Aatch there's no support of any kind for trait objects or closures yet. |
it's not as simple as deriving for normal types. to do it for traits and closures will require at least an extra vtable entry in the type representation. |
Apologies, misread the title slightly. |
I don't think we intend to support |
(In any case, this would require an RFC) |
A common idiom might be to create an arc or exclusive with a data structure inside, then spawn lots of worker tasks to walk over it. With #2829, it won't be possible to build a ~-closure and call it multiple times, since ARCs are noncopyable, since they need a special
clone()
interface.Add a factory-style interface that uses a
clone
trait to enable this pattern without the user getting their hands dirty copying around everything in a closure's environment.The text was updated successfully, but these errors were encountered: