E4078#
无法派生类型的特征。
MoonBit 允许你为你的某些类型派生某些特征的实现。然而,并非所有类型都能自动派生。例如,你无法为抽象类型派生特征。
错误示例#
type T derive(Hash) // Error: Cannot derive trait Hash for type T: target type is abstract
建议#
您可以手动实现该特性:
type T
impl Hash for T with hash_combine(self : T, hasher: Hasher) {
// ...
}