3 ms·
Why is a filtered iterator a different type than an unfiltered iterator?
by jeffdavis 8y ago
Why is a filtered iterator a different type than an unfiltered iterator?
- GolDDranks 8y agoThis is hard to answer as a one-liner; do you know about monomorphic vs. polymorphic code and static/dynamic dispatching? Rust is, by default statically dispatched, so because the two kinds of iterators do different things, they have to be of different types.
- jeffdavis 8y agoAh, that makes sense, thank you. One iterator simply returns the value and increments, and the other needs to apply the filter first and potentially advance several times.