Skip to content

Instantly share code, notes, and snippets.

@Mortimerp9
Last active December 22, 2015 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mortimerp9/6428577 to your computer and use it in GitHub Desktop.
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