{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreihqccpqke6zv7zhsekrke5u3tyitj6hvhzcevch6obeayy4u6335m",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mgutclus7iv2"
},
"path": "/t/introduce-a-way-to-construct-range-from-start-length/24073#post_9",
"publishedAt": "2026-03-12T14:57:48.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "I think that this would be a useful feature. My code has several examples of converting a start and length to `Range` to pass it elsewhere. (Many of them are `start..start + 1` to specify a single element.)\n\nHowever, the computation can have a numeric overflow, if `start + length` overflows. The appropriate behavior would need to be considered in the design of this function. Since `data[start..][..length]` reliably panics if the length is too large, it might be appropriate for `Range::from_len(start, length)` to panic too, even if `overflow-checks` are disabled.\n\nThis means that your point \"Doesn't have a possibility to express an invalid (`start > end`) range\" doesn’t _quite_ hold: on overflow, it _will_ have to deal with _that_ invalid input.",
"title": "Introduce a way to construct Range from start + length"
}