Hacker News new | ask | show | jobs
by dbaupp 4432 days 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`.