Skip to main content

E0019: Duplicate Field in Struct Literal

You specified the same field more than once in a struct literal.

Example

struct Point {
x: i64,
y: i64,
}

fn main() {
let p = Point { x: 1, y: 2, x: 3 }; // Error: field `x` is specified more than once
}

How to fix

Remove the duplicate field:

struct Point {
x: i64,
y: i64,
}

fn main() {
let p = Point { x: 1, y: 2 }; // OK
}