Ergonomics around wrapping thread creation / Passing closures to closures
⚓ Rust 📅 2026-03-09 👤 surdeus 👁️ 1Closures 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)
5 posts - 3 participants
🏷️ Rust_feed