Ruta graveolens  ·  notes from a language experiment  ·  cultivated since 2025

E0410: Duplicate method

CodeCategoryStability
E0410Struct and enumPermanent

Explanation

A struct definition declares more than one method or associated function with the same name. Both declaration forms share the struct's callable-member name space, so each callable member name must be unique within that struct; changing parameter types, count, return type, or mode does not create an overload.

Likely cause

A method or associated function was copied, renamed incompletely, or generated twice in one struct definition. Remove one declaration or give the callable members distinct names.

Examples

Duplicate method declaration

struct Point {
    x: i32,

    fn value(self) -> i32 { self.x }
    fn value(self) -> i32 { self.x }
}
fn main() -> i32 { 0 }

Give each method a unique name

struct Point {
    x: i32,

    fn value(self) -> i32 { self.x }
    fn doubled(self) -> i32 { self.x * 2 }
}
fn main() -> i32 { 0 }

References