3 ms·
Rust still offers an equivalent to things like switch (x) { case 0: case 1: foo(); break; case 2: case 3: bar(); break; default: baz(); } in the for
by dbaupp 13y ago
Rust still offers an equivalent to things like
switch (x) {
case 0: case 1: foo(); break;
case 2: case 3: bar(); break;
default: baz();
}
in the form of
match x {
0 | 1 => foo(),
2 | 3 => bar(),
_ => baz()
}
In any case, Rust's match is so much more powerful than switch, offering (nested) pattern matching like Haskell's `case`.