{
  "id": 4675152,
  "title": "RangeFrom, Part 2..: What I think is wrong about the design",
  "url": "https://urgent.news/2026/08/31/rangefrom-part-2-what-i-think-is-wrong-about-the-design",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-31T16:53:28.000Z",
  "source": {
    "name": "Lobsters",
    "slug": "lobsters",
    "url": "https://erk.dev/2026/08/30/rangefrom-part-2"
  },
  "original_language": "en",
  "account": "In December 2025, James Munns made a post about how RangeFrom just wraps around when it reaches the end. This led to the author forming several opinions and thoughts about it, which they want to share in this article. The article covers the properties people might expect from a RangeFrom iterator and demonstrates why they are incorrect.\n\nFor example, an iterator like let mut iter = (n..) would be expected to yield values from n onwards. However, the implementation detail of incrementing the internal counter before yielding the value means that overflow checking causes the iterator to overflow before yielding the final value (u8::MAX). The final value will then be the penultimate value before the overflow, which prints 253 and 254 and panics if overflow checks are enabled. If overflow checks are not enabled, it prints 255, and the iterator runs in an infinite loop.\n\nThe author's main issue with the current design is that RangeFrom behaves unexpectedly and breaks the concept of a range being something like [n, +∞). This inconsistency can be problematic, as it requires extra care when using RangeFrom as a guard for values. The only way to avoid this is by using n..={Integer}::MAX. However, this approach is not ideal for most types.\n\nTypes such as char, std::ascii::Char, Ipv4Addr, and Ipv6Addr do not follow the suggested behaviour but instead panics, wraps, or saturates when overflow occurs. The standard library inconsistently handles these types, with some panicking while others saturate or wrap. The author suggests documenting these behaviors and proposes adding an enumerate_with method to the Iterator trait to provide a more consistent and user-friendly solution.",
  "summary": null,
  "key_points": [
    "RangeFrom iterator wraps around at end, causing overflow issues",
    "Overflow checks yield penultimate value before panicking",
    "Inconsistent behavior across types leads to unpredictable results"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}