【发布时间】:2016-02-13 10:01:03
【问题描述】:
我正在尝试使用可克隆的迭代器对象定义结构。到目前为止,我已经达到了:
pub struct UseClonableIterator2<'a,T:'a> {
it: &'a (Iterator<Item=T> + Clone)
}
因为Clone 不是“内置特征”而无法编译:
x.rs:2:33: 2:38 error: only the builtin traits can be used as closure or object bounds [E0225]
x.rs:2 it: &'a (Iterator<Item=T> + Clone)
^~~~~
x.rs:2:33: 2:38 help: run `rustc --explain E0225` to see a detailed explanation
一个选项可能是为迭代器添加另一个类型参数,但这会使定义复杂化,我宁愿避免它。
【问题讨论】:
标签: rust