【发布时间】:2015-09-01 05:39:36
【问题描述】:
许多迭代器 implement the Clone trait,但没有一个 implement the Copy trait。至少对于像std:slice::Iter 这样的简单迭代器,the Clone implementation 无论如何看起来都像一个 memcpy,那么为什么 Copy 也没有实现呢?
【问题讨论】:
标签: rust
许多迭代器 implement the Clone trait,但没有一个 implement the Copy trait。至少对于像std:slice::Iter 这样的简单迭代器,the Clone implementation 无论如何看起来都像一个 memcpy,那么为什么 Copy 也没有实现呢?
【问题讨论】:
标签: rust
来自PR #20790:
此 PR 还使迭代器不可隐式复制,因为这是库中细微错误的来源。您仍然可以使用
clone()显式复制迭代器。
【讨论】:
for 循环并进行修改有关,但未修改 original 迭代器。