add enums and data holding enums
This commit is contained in:
7
containers/Cargo.lock
generated
Normal file
7
containers/Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "containers"
|
||||||
|
version = "0.1.0"
|
||||||
6
containers/Cargo.toml
Normal file
6
containers/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "containers"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
32
containers/src/main.rs
Normal file
32
containers/src/main.rs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
enum Direction
|
||||||
|
{
|
||||||
|
Up,
|
||||||
|
Down,
|
||||||
|
Left,
|
||||||
|
Right
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Status
|
||||||
|
{
|
||||||
|
Succeeded(String),
|
||||||
|
Failed(String)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// normal Enum
|
||||||
|
let direction = Direction::Down;
|
||||||
|
match direction {
|
||||||
|
Direction::Up => println!("Going up"),
|
||||||
|
Direction::Down => println!("Going down"),
|
||||||
|
Direction::Left => println!("Going left"),
|
||||||
|
Direction::Right => println!("Going right"),
|
||||||
|
}
|
||||||
|
|
||||||
|
// enum holding data
|
||||||
|
let status = Status::Failed(String::from("Authentication Failed"));
|
||||||
|
match status
|
||||||
|
{
|
||||||
|
Status::Succeeded(message) => println!("Succeeded with msg: {}",message),
|
||||||
|
Status::Failed(message) => println!("Failed with msg: {}",message),
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user