External Publication
Visit Post

Introduce a way to construct Range from start + length

Rust Internals [Unofficial] March 12, 2026
Source

scottmcm:

Reminder that, at least if you're slicing, [start..][..count] works wonderfully.

Maybe we could have something like:

impl<T: Step> RangeFrom<T> {
    fn with_len(self, count: usize) -> Range<T> {
        self.start.clone()..self.start.forward(count)
    }
}

e.g. (start..).with_len(count)

Step can allow checked/unchecked variants as well.

Discussion in the ATmosphere

Loading comments...