这个akka-http测试在哪里导入Marshaller?

Where does this akka-http test import Marshaller?

我正在查看这个 akka-http 文档示例(链接到 akka-http 测试代码):

Marshalling

这实际上是来自 github 代码 MarshalSpec.scala 的测试。我的问题是,这里导入的隐式 Marshaller 在哪里?我正在查看进口商品,但找不到?我尝试使用 IntelliJ 向我展示隐式导入,但我仍然无法弄清楚。获取传递给 Marshaller 的隐式声明的 import 语句在哪里:

  val entityFuture = Marshal(string).to[MessageEntity]

在第 21 行? 它调用

def to[B](implicit m: Marshaller[A, B], ec: ExecutionContext): Future[B] =

在 Marshal.scala 中并传递一个隐式的 m: Marshaller,我无法确定它。

Marshaller 扩展了 PredefinedToEntityMarshallers ,它提供了 String.

的编组

但是,为什么 Marshaller 带有自己的隐含函数?这是因为 scala 在类型参数的隐式范围内搜索隐式:Where does Scala look for implicits?

因此,Marshaller 自带了自己的 Marshaller,随时可用 :)