Why aren't iterators copied?

Many iterators implement the Clone trait , but none of them implement the Copy trait . At least for simple iterators like std:slice::Iter , the Clone implementation is anyway similar to memcpy, so why isn't Copy implemented?

+6
source share
1 answer

From PR # 20790 :

This PR also makes the iterator implicitly copied, as it was the source of subtle errors in libraries. You can still use clone() to explicitly copy the iterator.

+8
source

All Articles