Skip to content

Instantly share code, notes, and snippets.

@Mortimerp9
Last active December 22, 2015 06:08
Show Gist options
  • Select an option

  • Save Mortimerp9/6428577 to your computer and use it in GitHub Desktop.

Select an option

Save Mortimerp9/6428577 to your computer and use it in GitHub Desktop.
Because in scala `Try` is a kind of `Future` that doesn't run on a separate thread
import scala.util.{Failure, Success, Try}
import scala.concurrent.future
implicit def tryToFuture[T](t: Try[T]): Future[T] = t match {
case Success(s) => Future.successful(s)
case Failure(t) => Future.failed(t)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment