Closures are great. Very convenient for quickly defining a function to factor out some logic. Especially how they infer types.
Until I want to factor out some code when I'm starting a handful of threads. Then the twin facts that every closure is its own type, and that we apparently don't have generic closures yet rear their ugly heads.
If I want to pass closures as parameters to closures, are these my only options?
Upgrade the outer closure to a function, and have to explicitly write out all the trait bounds, which are potentially long and ugly (because apparently functions don't have type inference like closures)
Change the outer closure to a macro. (probably the easier of the two options, but feels like giving up)
Note in particular the use of std::thread::Result. And if that type alias did not already exist, you could define it yourself, for the sake of naming this Sender and its corresponding Receiver type.
Not me, but I have been drifting in that direction. It was saving me a few headaches, but there is a clippy lint for it, I suppose, so I'll change my ways.
That lint is marked as "restriction", which means that the lint does not represent an endorsement of a particular coding style. It's just a thing you can enable on a lint-by-lint basis for specific purposes.