Skip to content

Instantly share code, notes, and snippets.

@jcar787
Created April 1, 2022 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcar787/a103dcba5539c624decb081013139a39 to your computer and use it in GitHub Desktop.
Save jcar787/a103dcba5539c624decb081013139a39 to your computer and use it in GitHub Desktop.
Enum example in Rust
enum StagesInLife {
Birth(String),
Grow,
Work(String),
Retirement { age: u8, pension: f32 }
}
fn main() {
let birth = StagesInLife::Birth("Jeff".to_string());
let grow = StagesInLife::Grow;
let work = StagesInLife::Work("Principal Software Engineer".to_string());
let retire = StagesInLife::Retirement { age: 43, pension: 5000.55 };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment