1
我有点惊讶,这段代码不会编译。作为新生锈,有可能我做了,当然一些愚蠢的错误...如何使用enum作为数组元素?
mod board {
enum Square {
Empty,
Black,
White
}
fn init() -> [Square;9] {
[Square::Empty; 9]
}
}
main.rs:10:9: 10:27 error: the trait
core::marker::Copy
is not implemented for the typeboard::Square
[E0277] main.rs:10 [Square::Empty; 9]
或者是一个语言的非功能,枚举不允许作为数组元素类型?
请注意,我需要克隆添加到导出为它工作。 '#[导出(复制,克隆)]' – agmcleod 2015-12-06 18:09:02