3 ms·
Even that is better in Rust (using the enum from the end): match i % 15 { 0 => FizzBuzz, 5 | 10 => Buzz, 3 | 6 | 9 | 12 => Fizz,
by chrismorgan 12y ago
Even that is better in Rust (using the enum from the end):
match i % 15 {
0 => FizzBuzz,
5 | 10 => Buzz,
3 | 6 | 9 | 12 => Fizz,
_ => Number(i),
}
- taeric 12y agoI actually agree it is better. But... my point was that the switch statement was already pretty readable. If there are gains, they feel pretty small in these examples. And to be clear, I like pattern matching. A lot. I just don't feel this really shows it off that well.
- icedog 12y agoWhat do you expect; it's FizzBuzz.
- mattmanser 12y agoOnly because you're expecting the cases to fall through, you're being blinded by your own expectation. Your code is considered bad practice in many languages.