4 ms·
May be worth moving to rustc, because that's not just bad style, that's incorrect code.
by pornel 6y ago
May be worth moving to rustc, because that's not just bad style, that's incorrect code.
- estebank 6y agoI don't disagree but it feels like the bulk of the likely problema would be when not dealing with literals.
- rtpg 6y agoI disagree, sometimes you end up building empty ranges in your code for valid reasons (as a result of math, for example). special casing a check on literals feels a bit like saying you can create an empty non-mutable vector.
- baby 6y agoI disagree, if this happens you want to document these edge-cases by failing early, this is very bad code if you don't and let the loop happen when most reviewers would have no idea if the result would be an unexpected behavior or not.
- estebank 6y agoIf I had a need for that I would write a surprised snake (0..0) instead.
- carlmr 6y agoExactly. (5..0) is almost surely a developer that expects the range 5, 4, 3, 2, 1