https:/www.playframework.comdocumentation2.8.0apiscalaplayapimvcQueryStringBindable.html
这个例子和许多其他例子在创建OueryStringBindable隐式时总是实现bind和unbind,我们真的需要同时实现吗?
两种 QueryStringBindable.{unbind,bind}
是抽象的,所以它们需要被实现(而不是被覆盖,因为在trait中没有默认实现)。
A QueryStringBindable
也可以从所提供的衍生。
case class Foo(name: String)
object Foo {
// Derive with `transform` ...
implicit val queryStringBindable: QueryStringBindable[Foo] =
implicitly[QueryStringBindable[String]].transform[Foo](
{ name: String => Foo(name) },
{ foo: Foo => foo.name })
}