Skip to content

Commit 2dcaac7

Browse files
committed
enum demo
1 parent 7636658 commit 2dcaac7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

code/examples/demo_enum/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "demo_enum"
3+
version = "0.1.0"
4+
authors = ["jameskk <[email protected]>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fn main() {
2+
enum Animal {
3+
dog = 1,
4+
cat = 200,
5+
chicken,
6+
tiger,
7+
}
8+
println!("tiger is: {}", Animal::tiger as isize);
9+
println!("dog is: {}", Animal::dog as isize);
10+
println!("cat is: {}", Animal::cat as isize);
11+
}

0 commit comments

Comments
 (0)