'Higher order inline functions, and MDCContext

So I'm trying to write a higher order function that adds Mapped Diagnostic Context (MDC) to a closure that is passed as parameter.

There are two ways to make it work. One for non suspending functions (MDC.put) and one for suspending functions (MDCContext)... But is there a way to make it work in any kind of functions?

I know there's no "suspending variance", other than using the inline modifier, yet...

Just curious!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source