Basically, I want to get this code to compile:
I know why this does not compile. But I don’t know how I can solve it instead. I tried a couple of different things, including wrapping the closures in Box::new(), but I couldn’t get it to work.
At first, I wanted to ignore the problem and just move all the sorting logic, including the conditionals, inside a single closure. But then I had to add a reverse sorting option. Because I really would like to use
*_by_key for simplicity, I tried with std::cmp::Reverse, and this happened:
Again, I understand why the error occurs, but I am not sure how to fix it.
Any help appreciated.