E4005

E4005#

This error occurs when a trait has multiple declarations of the same method name. Each method in a trait must have a unique name to avoid ambiguity.

Erroneous example#

trait Animal {
  make_sound(Self) -> String
  make_sound(Self) -> String  // Error: method make_sound is declared twice
}

Suggestion#

Remove the duplicate method declaration and keep only one definition for each method name:

trait Animal {
  make_sound(Self) -> String  // Only declare the method once
}

If you need different method behaviors, use distinct method names:

trait Animal {
  make_sound(Self) -> String
  make_loud_sound(Self) -> String  // Use a different name for different behavior
}