Rust 1.40 adds a feature that stops consumers matching on structs or enums exhaustively, so extending them is not a breaking change!
There's a cute todo!() macro too.
miniblog.
Related Posts
I really like pattern matching in Rust, but I find myself using it less and less.
`if let` and `let ... else` require substantially less indentation, and I often use them for Option values.
I don't miss this syntactic sugar in OCaml though. Maybe it's just because OCaml has a 2 space indent, unlike Rust's 4 space indent?
Are there any languages that have both pattern matching and statement oriented syntax?
In principle these are orthogonal, but I'm struggling to think of a language with pattern matching that isn't expression oriented.
"If it compiles it probably works" is definitely more common in some languages.
What PL features make this more likely?
My current theory is that pattern matching on enums with exhaustiveness checking is the primary cause. Especially when null has been replaced with Option.