Add enum example
This commit is contained in:
parent
99d13b5a2f
commit
307c5c1e39
2 changed files with 21 additions and 0 deletions
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