Skip to main content

E0023: Unknown Enum Variant

You referenced a variant that doesn't exist on the enum.

Example

enum Color {
Red,
Green,
Blue,
}

fn main() {
let c = Color::Yellow; // Error: enum `Color` has no variant named `Yellow`
}

How to fix

Use a variant that exists on the enum:

enum Color {
Red,
Green,
Blue,
}

fn main() {
let c = Color::Red; // OK
}

Or add the variant to the enum definition if needed.