Add enum example
This commit is contained in:
parent
99d13b5a2f
commit
307c5c1e39
2 changed files with 21 additions and 0 deletions
9
enum_example/Cargo.toml
Normal file
9
enum_example/Cargo.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "enum_example"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["laurens <miers132@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
12
enum_example/src/main.rs
Normal file
12
enum_example/src/main.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#[derive(Debug)]
|
||||||
|
enum IpAddrKind {
|
||||||
|
V4(u8, u8, u8, u8),
|
||||||
|
V6(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let v4 = IpAddrKind::V4(127, 0, 0, 1);
|
||||||
|
let v6 = IpAddrKind::V6(String::from("::1"));
|
||||||
|
|
||||||
|
println!("Ipv4: {:#?}, Ipv6: {:#?}", v4, v6);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue