State of FnBox?

Hi!

I was looking to resume work on a hobby project that heavily uses boxed closures. Back then, it seems I switched to nighly and used #![feature(fnbox)].

What's the state of boxed closures now? I see issue #28796 but no workaround in sight. Also, fn_box on crates.io doesn't compile on stable.

Am I stuck on nightly or is there a way to used boxed closures on stable?

Thanks in advance!

Cheers,
Kosta

You can make them work with a bit of indirection: https://github.com/sfackler/r2d2/blob/master/src/thunk.rs

So, the trick is to

  • Declare a "hidden" trait that you can implement for FnOnce
  • Implement it for Box<Self> generically

Looks good. I'll try it out!

Thanks for your advice!