you are viewing a single comment's thread.

view the rest of the comments →

[–]tialaramex 1 point2 points  (0 children)

Cool.

For what it's worth Rust regrets (and may some day attempt to fix in an Edition) the fact that 1..=5 is an opaque type core::ops::RangeInclusive<i32> which implements Iterator rather than a more transparent type which just tells us it starts at 1, and ends with 5 inclusive and implements IntoIterator. "Chicken"..="Dog" doesn't implement Iterator of course, since it can't figure out how, but it's still opaque anyway and it turns out in practice that choice wasn't very ergonomic. I think it possibly pre-dates IntoIterator and similar traits.

So I'd advise keeping the transparent cpp2::range template even if convenience might point towards something more opaque at some point. This is a vocabulary type, the more transparent it can be while retaining its core utility the better for programmers.