Enum is used to create a new type from selecting one of predefined constant values.

Rust Enum

Here is an syntax for Enum

enum enum_name{
    VALUE1,
    VALUE2,
    ----
    VALUEN
}
#[derive(Debug)]

enum Status {
    ACTIVE,
    INACTIVE,
}

fn main() {
    let active = Status::ACTIVE;
    let inactive = Status::INACTIVE;
    println!("{:?}", active);
    println!("{:?}", inactive);
}

Output:

ACTIVE
INACTIVE

#[derive(Debug)] statement added to avoid the below compilation error. As Enums can not be formatted with {:?}

println!("{:?}", inactive); | ^^^^^^^^ Status cannot be formatted using {:?} | = help: the trait Debug is not implemented for Status = note: add #[derive(Debug)] to Status or manually impl Debug for Status = note: this error originates in the macro $crate::format_args_nl (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors