E4079#
Cannot derive trait: method is already defined.
This error occurs when you try to derive a trait for a type that already has a implementation for the trait.
错误示例#
impl Show for A with output(self : A, logger : &Logger) -> Unit {
logger.write_object(self._)
}
type A Int derive(Hash, Show) // Error: Cannot derive trait Show for A: method output is already defined at ...
建议#
You can pick either the manual implementation or the derived implementation for the type by removing the other one.
To use the derived implementation:
// Remove the manual implementation
// impl Show for A with output(self : A, logger : &Logger) -> Unit {
// logger.write_object(self._)
// }
type A Int derive(Hash, Show)
Or to use the manual implementation:
impl Show for A with output(self : A, logger : &Logger) -> Unit {
logger.write_object(self._)
}
type A Int derive(Hash)