26.1 Type
#1269
Replies: 1 comment
-
Converted to #1350. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I had a few questions/thoughts on this section.
type Item
is, unless I missed it.Self::Item
withu32
, but of course you can't.take(5)
is obviously to prevent overflow, but I think it's more interesting without that. At least, I think you might suggest the instructor or student removes it. It doesn't take too long to run and the output is great:I did think, however, that while this is an interesting iterator, it's a slightly weird example, being "apparently" infinite but actually only only capable of producing 46 results before overflowing. Would it be better to handle the overflow and terminate iteration when you get past the capacity of an u32? (The implementation is slightly weird too, in the it overflows one sooner than it needs to. 1,134,903,170 + 1,836,311,903 is obviously less than 4 billion (2,971,215,073) and is already stored in
next
.It also feels like a slightly odd example in that
.next()
mutates the item in a pretty fundamental way. But maybe that's not usual? Not sure. It felt like a slightly weird example to me.Beta Was this translation helpful? Give feedback.
All reactions