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

Passing members as closures. #13813

Closed
ddrcoder opened this issue Apr 28, 2014 · 2 comments
Closed

Passing members as closures. #13813

ddrcoder opened this issue Apr 28, 2014 · 2 comments

Comments

@ddrcoder
Copy link

I can't seem to figure out how to pass member functions as closures. I can do this:

fn my_unwrap<T>(o: Option<T>) -> T { o.unwrap() }

// name non-member function
let vals = opts.map(my_unwrap);
// take value, call member
let vals = opts.map(|o| o.unwrap());
// pass member function...?
let vals = opts.map(Option::unwrap); // doesn't compile

But I see no way to pass the actual member function within std::Option. Perhaps I missed something in the documentation?

@ddrcoder
Copy link
Author

This particular case could be done with filter_map, I know, but the general question remains.

@alexcrichton
Copy link
Member

This will be enabled with something we call "uniform function call syntax", closing as a dupe of #11938

For now, this is not possible, sadly.

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

2 participants