-
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
RFC: Implement Clone on |A|: 'static -> R
&'static fn()`
#8025
Comments
I think this is a change requiring an RFC. Nominating so we can discuss it in triage. |
Seems like a fine thing to do. We'll need a couple of impls for differing numbers of arguments. |
Good newbie bug. |
assigned to P-low to reflect that its not a big deal for 1.0 though. |
I just encountered a case where I think I want this. The details, for those interested: I'm trying to set up a condition-like system, but where the exception responses are carried in objects rather than derived from the dynamic scope. I also want to be able to have child object initially set up its exception handler as a copy of the exception handler of the parent. I'm pretty sure the "obvious thing" is to use objects instead of closures here, since the objects could obviously implement clone, but it would be nice to inter-operate with functions, even if only ones that can be &'static borrowed. |
So, there is some confusion between the spellings of various types -- what was |
&'static fn()
|A|: 'static -> R
&'static fn()`
Edited the title to match the current syntax for closures. I believe this is an example test case if this were implemented.
|
I think we ought to just close this issue. It'd require an RFC and would interact with plans for "unboxed closures" (#8622). |
Rustup Re-sync, because I didn't get to syncing things back to rustc. r? `@ghost` changelog: none
Some closures are shallow-clonable and should implement .clone().
One example is a
&'static fn(A) -> R
autoborrowed from an extern fn. If it's clonable then that could make an iterator adaptor likeMapIterator
clonable in some cases.The text was updated successfully, but these errors were encountered: