E4077#
Don’t know how to derive trait for type.
MoonBit allows you to derive implementation of some pre-defined traits for your types. It means that you cannot have MoonBit automatically derive a trait that you defined yourself.
错误示例#
trait T {
f(Self) -> Int
}
type A Int derive(T) // Error: Don't know how to derive trait T for type A
建议#
You can implement the trait manually:
trait T {
f(Self) -> Int
}
// Remove derive(T)
type A Int
impl T for A with f(self : A) -> Int {
0
}