Skip to content

Instantly share code, notes, and snippets.

@gkmngrgn
Created April 25, 2024 13:09
Show Gist options
  • Save gkmngrgn/1c61bc8d6ce650ff9144fc83a6941b07 to your computer and use it in GitHub Desktop.
Save gkmngrgn/1c61bc8d6ce650ff9144fc83a6941b07 to your computer and use it in GitHub Desktop.
Enum example from Rust
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