actix-net icon indicating copy to clipboard operation
actix-net copied to clipboard

Make System::with_tokio_rt take a `FnOnce`

Open DzenanJupic opened this issue 2 years ago • 0 comments

System::with_tokio_rt currently takes a Fn, which is quite restricting, since it does not allow moving ownership of captured variables into the closure (at least not in a clean way). This is especially useful if the runtime had to be initialized before the system and was stored in a global variable or passed as an argument.

The code in with_tokio_rt only calls the closure once, and since Fn: FnMut and FnMut: FnOnce, this should not be a breaking change.

DzenanJupic avatar Mar 18 '22 06:03 DzenanJupic