Wrap function implementations returning a specific type into another function programatically
问题 I would like to wrap all the user defined functions in a scala project that return a certain type T , into a function that accepts a T and the function name as parameters. eg. given this function is in scope: def withMetrics[T](functionName: String)(f: => Try[T]): Try[T] = { f match { case _: Success[T] => println(s"send metric: success for $functionName") case _: Failure[T] => println(s"send metric: failure for $functionName") } f } the user can send metrics for their functions which return