4 ms·
I really like Rust's pattern matching, but my opinion on this particular part of the code is exactly the opposite. I think it would have been more readable if i
by ceronman 12y ago
I really like Rust's pattern matching, but my opinion on this particular part of the code is exactly the opposite. I think it would have been more readable if it used simple if statements:
if (width == auto) {
...
}
else if (margin_left == auto && margin_right == auto) {
...
}
else if (margin_left == auto) {
...
}
else if (margin_right == auto) {
...
}
else {
...
}
Perhaps I'm not very used to the pattern matching notation.
- 8_hours_ago 12y agoThe code from the article has comments at the beginning of each block, which makes it very easy to read to me. But of course, that requires the programmer to actually write comments and keep them up-to-date. I bet you could write some incredible spaghetti code with this style of pattern matching. The if statements you wrote are at least somewhat self-documenting, and harder to shoot yourself in the foot with.
- mbrubeck 12y agoI agree this is more readable on its own, but it no longer matches the order of the prose in the CSS spec. One of my goals was easy comparison against the specification text.