All Downloads are FREE. Search and download functionalities are using the official Maven repository.

munit.internal.FutureCompat.scala Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
package munit.internal

import scala.concurrent.Future
import scala.util.Try
import scala.concurrent.ExecutionContext

object FutureCompat {
  implicit class ExtensionFuture[T](f: Future[T]) {
    def flattenCompat[S](
        ec: ExecutionContext
    )(implicit ev: T <:< Future[S]): Future[S] =
      f.flatten
    def transformCompat[B](
        fn: Try[T] => Try[B]
    )(implicit ec: ExecutionContext): Future[B] = {
      f.transform(fn)
    }
    def transformWithCompat[B](
        fn: Try[T] => Future[B]
    )(implicit ec: ExecutionContext): Future[B] = {
      f.transformWith(fn)
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy