External Publication
Visit Post

Introduce a way to construct Range from start + length

Rust Internals [Unofficial] March 12, 2026
Source

Currently the only way to construct such range is via start..(start + length)

Instead, we would be able to do it via Range::from_len(start, length)

Or, via a new custom syntax start..+length

  • This would help avoid off-by-one errors / wrongly defined ranges (ex: start..length)
  • Doesn't have a possibility to express an invalid (start > end) range
  • Reduce boilerplate (repeating start)
  • Is generally the more natural way to express a range

(Instead of len/length it can be count/width/offset)

Discussion in the ATmosphere

Loading comments...