|
|
|
|
|
by stonemetal
4264 days ago
|
|
It must just be a matter of familiarity. Rust's pattern matching is quite similar to other languages with pattern matching. For example in OCaml the match statement would be: match ( i mod 3, i mod 5) with
| (0,0) -> Printf.printf "Fizzbuzz"
| (0,_) -> Printf.printf "Fizz"
| (_,0) -> Printf.printf "buzz"
| (_,_) -> Printf.printf "%d" i
Other than the irrelevant syntax bits like 'with', the semantics are identical, in order matching with no fall through, and _ for unnamed and unused bindings.To me with very limited experience in it, Rust really feels like OCaml with a skin that C programmers will understand. |
|