盒子和数组是可复制的,为什么这段代码无法编译?
#[derive(Debug, Copy, Clone)]
enum Octree{
Branch(Box<[Octree; 8]>),
Filled,
Empty,
}
编译错误:
main.rs:3:17: 3:21 error: the trait `Copy` may not be implemented for this type; variant `Branch` does not implement `Copy` [E0205]
编辑: 好的,我不想让Octree
可复制。但是我怎么才能使其可变呢?我想要能够更改节点的子项。
[Octtree::Empty, Octtree::Empty, Octtree::Empty, Octtree::Empty, Octtree::Empty, Octtree::Empty, Octtree::Empty, Octtree::Empty]
。问题解决了。(是的,我对此非常认真。如果您想使用数组,那就是您要做的。) - Chris Morgan