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.