Skip to content
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

Function pointers should implement the various Fn* types #17961

Closed
carllerche opened this issue Oct 12, 2014 · 3 comments
Closed

Function pointers should implement the various Fn* types #17961

carllerche opened this issue Oct 12, 2014 · 3 comments

Comments

@carllerche
Copy link
Member

The following should work:

#![feature(unboxed_closures)]
#![feature(overloaded_calls)]

fn action<F: FnOnce() -> ()>(cb: F) {
    cb();
}

fn foo() {
    println!("In foo");
}

pub fn main() {
    action(foo);
}
@ftxqxd
Copy link
Contributor

ftxqxd commented Oct 12, 2014

#15448 was already filed to let functions implement FnMut, and was fixed, so all that is required now is the unboxed closure trait hierarchy for the other traits to work as well.

@aturon aturon mentioned this issue Oct 16, 2014
47 tasks
@japaric
Copy link
Member

japaric commented Nov 19, 2014

This is working now (I think it has been working for a while).

@alexcrichton
Copy link
Member

Thanks @japaric!

lnicola pushed a commit to lnicola/rust that referenced this issue Aug 29, 2024
internal: Don't allocate autoderef steps when not needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants