How to "unquote" a string literal

The problem with this reasoning is that we don’t know what the volume of questions would have been if the decision had gone the other way. Perhaps everything would be better, but this also might be a cursed design problem where every solution generates lots of strife.

2 Likes

Not only that, but it's also pretty reasonable to expect that people are asking on a forum when they are puzzled, and not when they know exactly what to do. And the proportion of questions related to ranges being iterators is… just not that high at all. I don't even remember the last time I encountered one, in contrast with e.g. borrowck or generics questions, which pop up multiple times a day.

1 Like

Mind you, map isn't the only method in Iterator. Surely you wouldn't want two parallel implementations where every inherent method on Range has to be updated to match its counterpart in Iterator, that would be just dull (and in fact, it would be a clearly bad design decision, unlike the iterability of ranges).

1 Like

I would think that if the problem with using into_iter with ranges explicitly would be too complicated then maybe it's better to expand IntoIter trait with default implementation of some Iterator function rather then turn something which is conceptually not an iterator to be one for the same of brevity.

The fact that Range is not Copy and is an Iterator is very confusing for newbies (and even lots of people with experience) while argument “we want to call map directly on range” doesn't sound too convincing: why is that not a problem for Vec or HashMap, but is problem for range? What makes range special?

1 Like

I don't think and didn't assert it would be too complicated. I wouldn't personally mind writing into_iter() in one more case, and I wouldn't mind if ranges were IntoIterator instead of Iterator. I was just trying to say that the status quo is not obviously inferior to the alternative.

Range is not special but it's much more trivial than any collection. Making proper collection types implement Iterator would require additional bookkeeping besides their primary storage, and it would also prevent multiple borrowers from iterating over the same collection simultaneously. This is not really a concern with Range, as it requires no additional storage to store its iteration state, and it's trivial and cheap to clone when necessary.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.