You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
I can't seem to figure out how to pass member functions as closures. I can do this:
But I see no way to pass the actual member function within
std::Option
. Perhaps I missed something in the documentation?The text was updated successfully, but these errors were encountered: