E4077

E4077#

不知道如何导出类型的特征。

MoonBit 允许你为你的类型派生一些预定义特征的实现。这意味着你无法让 MoonBit 自动派生你自定义的特征。

错误示例#

trait T {
  f(Self) -> Int
}

type A Int derive(T) // Error: Don't know how to derive trait T for type A

建议#

您可以手动实现该特性:

trait T {
  f(Self) -> Int
}

// Remove derive(T)
type A Int

impl T for A with f(self : A) -> Int {
  0
}