This makes 1.iter().chain(…) possible which is cleaner than other ways.
What other ways have you evaluated? How about Some(1).into_iter().chain(...)
? Or std::iter::once(1)
? The advantage is that these can be used for singletons of any type, rather than adding something special to numbers.
1 Like
It’s also not clear whether 4.iter() is supposed to be an iterator of the numbers 1 to 4, or an iterator of one item that is 4, or something else. Although it does mean some more typing, I’d prefer to use existing iterator methods with unambiguous meanings like once() and repeat().take() for simple numeric sequences like that.
5 Likes
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.