Enums
Rust follows F#, Haskell pattern
Enums
Enums are really peculiar in Rust. For instance below is a valid enum
fn main() {
let address = Test::V6(String::from("::1"));
println!("{:?}", address);
}
#[derive(Debug)]
enum Test {
V4,
V6(String),
}
As you could see above, enums could hold different values.
Null Values
There is no null value in Rust. Keep this in mind. Instead you could use pre-build enums from the standard library like Option<T> or Result<T, Error>
Last updated
Was this helpful?