Variant is never constructed in ENUM

I've the below enum:

pub enum AppAction {

But I'm getting the below warnings:

warning: variant is never constructed: `Task`
 --> src\models\
2 |     Task,
  |     ^^^^
  = note: `#[warn(dead_code)]` on by default

What are these?

It simply means that the variant is never used, "constructed", anywhere in your program.

1 Like

There is no AppAction::Task anywhere in the program. Rust expects that if you say an enum variant exists, you will use it for something somewhere.


during development, when there's various enumerants that you intend to use later—it can be somewhat annoying to see this all the time

by putting this before the enum, or individually before intentionally unused items, you can make the warning disappear:


the warning also goes away when the enum is in a crate and public, because the compiler can't know if it's used anywhere

1 Like

On the other hand, you are not going to forget them!


You are correct, I may have to live with them tell the app be completed.