Created
April 25, 2024 13:09
-
-
Save gkmngrgn/1c61bc8d6ce650ff9144fc83a6941b07 to your computer and use it in GitHub Desktop.
Enum example from Rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum IpAddrKind { | |
V4, | |
V6, | |
} | |
struct IpAddr { | |
kind: IpAddrKind, | |
address: String, | |
} | |
let home = IpAddr { | |
kind: IpAddrKind::V4, | |
address: String::from("127.0.0.1"), | |
}; | |
let loopback = IpAddr { | |
kind: IpAddrKind::V6, | |
address: String::from("::1"), | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment