External Publication
Visit Post

Introduce a way to construct Range from start + length

Rust Internals [Unofficial] March 14, 2026
Source

scottmcm:

How about just a function? Range::from_start_and_len(start, length) would be fine, no new type.

I'll ask again: what is the type signature of from_start_and_len? Are both T? If so, what of the signed types and negative length? Perhaps T and Into<T::Unsigned> to at least remove the negative-ness concern? Should there be a try_ variant that catches that and overflow? If it is "just" Add-gated, what about floating point types? What is f32::Unsigned if that path is chosen? Or perhaps this only makes sense for usize at all?

Discussion in the ATmosphere

Loading comments...