Perseids
Perseids

Reputation: 13250

Why are iterators not copyable?

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?

Upvotes: 9

Views: 850

Answers (1)

DK.
DK.

Reputation: 59135

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.

Upvotes: 10

Related Questions