Why are iterators not copyable?

2019-06-20 08:34发布

问题:

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 looks like a memcpy anyway, so why isn't Copy also implemented?

回答1:

From PR #20790:

This PR also makes iterator non-implicitly copyable, as this was source of subtle bugs in the libraries. You can still use clone() to explictly copy the iterator.



标签: rust