diff options
-rw-r--r-- | enumeration/.gitignore | 18 | ||||
-rw-r--r-- | enumeration/Cargo.toml | 9 | ||||
-rw-r--r-- | enumeration/src/main.rs | 25 |
3 files changed, 52 insertions, 0 deletions
diff --git a/enumeration/.gitignore b/enumeration/.gitignore new file mode 100644 index 0000000..e629269 --- /dev/null +++ b/enumeration/.gitignore @@ -0,0 +1,18 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/rust +# Edit at https://www.toptal.com/developers/gitignore?templates=rust + +### Rust ### +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# End of https://www.toptal.com/developers/gitignore/api/rust + diff --git a/enumeration/Cargo.toml b/enumeration/Cargo.toml new file mode 100644 index 0000000..f956b97 --- /dev/null +++ b/enumeration/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "enumeration" +version = "0.1.0" +authors = ["Jordan Gong <jordan.gong@protonmail.com>"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/enumeration/src/main.rs b/enumeration/src/main.rs new file mode 100644 index 0000000..f310ad6 --- /dev/null +++ b/enumeration/src/main.rs @@ -0,0 +1,25 @@ +enum Message { + Quit, + Move { x: i32, y: i32 }, + Write(String), + ChangeColor(i32, i32, i32), +} + +impl Message { + fn call(&self) { + + } +} + +fn main() { + enum IpAddr { + V4(u8, u8, u8, u8), + V6(String), + } + + let home = IpAddr::V4(127, 0, 0, 1); + let loopback = IpAddr::V6(String::from("::1")); + + let m = Message::Write(String::from("hello")); + m.call(); +} |