Scala map a Vector of tuples to vector of object <pre><code>import scala.concurrent.duration._ import scala.language.implicitConversions import scala.concurrent.{Future, Await} import scala.concurrent.ExecutionContext.Implicits.global object test extends App { case class Person(name: String, age: Int) implicit def t2p(t: (String, Int)) : Person = Person(t._1, t._2) val f:Future[Vector[(String, Int)]] = Future { Vector(("One", 1), ("Two", 2)) } val s = f.mapTo[Vector[Person]] Await.result(s.map { _ foreach { x =&gt; println(x)}}, 5.seconds) } </code></pre> <p>I am trying to convert a Vector of tuples to a Vector[Person] but the above code result in a casting exception even though there is an implicit tuple to Person conversion function?</p> <p>Exception in thread "main" java.lang.ClassCastException: scala.Tuple2 cannot be cast to example.test$Person at example.test$$anonfun$2$$anonfun$apply$1.apply(test.scala:19) at scala.collection.Iterator$class.foreach(Iterator.scala:727) at scala.collection.AbstractIterator.foreach(Iterator.scala:1157) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at example.test$$anonfun$2.apply(test.scala:19) at example.test$$anonfun$2.apply(test.scala:19)</p> <p>Thanks.</p>