Want for intermediate Rust book / docs: a clean cut tutorial on how to implement the Iterator trait. Took a while to figure out that for many cases we need to create a secondary struct that holds / borrows the primary struct and adds a counter / lifetimes. This isn't documented.
Good question! I don't have an answer haha. From practice I think I agree it's good to always have a secondary struct.
-
-
I think it's necessary, as you can easily end up with two independent iterators over the same struct, so you can't rely on the struct itself to track the position.
-
No, hold on, I guess if it's a consuming iterator you could get away with it, as you can only have one of those, but it's probably still a lot easier with a secondary struct.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.