If I have a enum that imitates an option type, it can either contain some value, or nothing:
enum option {
some(u8),
none,
}
Then I can pattern match it like this:
let x = option::some(8);
match x {
some => println!("some"),
none => println!("none"),
}
But what if I want to pattern match the value inside the some? Intuitively, I think it would be something like so:
match x {
some(x) => println!("{}", x),
none => println!("none"),
}
But Rust has no idea what this is.
I also try to see if the some itself is the u8 value:
match x {
some => println!("{}", some),
none => println!("none"),
}
This also does not work. How do I get the value inside the enum?