Better Enumerations in Python
When dealing with more than one language, we look for similar approaches across languages. In Rust, there’s a keyword called enum to define and use enumerations. It’s easy to use, let’s look at this example from the official document: 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"), }; Rust ...