-
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
fn() does not implement FnMut #15448
Comments
Even with this: use std::ops::Fn;
fn foo(i: int) -> int
{
i
}
fn main()
{
println!("{}", (&foo as &Fn<int, int>).call(1));
} I get the error:
|
Nominating for 1.0, P-backcompat-lang. This is something I forgot and will be necessary for unboxed closures to work properly. |
Assigning 1.0 milestone, P-backcompat-lang. |
Updated title: |
I'm having second thoughts about this; I don't see a good way to fit the implementation well into the existing vtable infrastructure, it was never covered by an RFC as far as I know, and it isn't necessary for anything to work (just convenient in some cases). It is not clear to me that, if we do this, whether we should do this as a coercion from bare functions to unboxed closures (similar to how we do these things today) or whether it should be a special kind of vtable or... something. Anyway I'm nominating for removal from the 1.0 milestone to reduce scope creep. |
My initial thoughts:
Regarding the last point, you'd prefer to write:
But you can't. Given variadic generics, or if we used tuples more consistently in fn types, we'd be fine, I think. |
This is done entirely in the libraries for functions up to 16 arguments. A macro is used so that more arguments can be easily added if we need. Note that I had to adjust the overloaded call algorithm to not try calling the overloaded call operator if the callee is a built-in function type, to prevent loops. Closes rust-lang#15448.
This does not compile:
The text was updated successfully, but these errors were encountered: