Warning
This post was published 37 days ago. The information described in this article may have changed.
I have a data structure whose Iterator could implement .take(n) simply by adjusting a number in the Iterator, which would generally be much more efficient than counting down the number of elements returned in a wrapping Iterator. Same for .skip(n). I thought that slice's Iterator must do an optimization like this, but unless I'm misreading the code (which is certainly possible), it just uses the blanket Iterator version of Take that counts down. Does it really use the slow default implementation? Is there some reason why it doesn't provide a custom implementation?
4 posts - 4 participants
🏷️ rust_feed