當我試圖編譯這段代碼,我得到了E0508錯誤:我不明白,錯誤E0508
cannot move out of type
[Enum; 2]
, a non-copy fixed-size array
enum Enum {
Val1 = 0,
Val2 = 1,
}
fn main() {
let a = [Enum::Val1, Enum::Val2];
let x: i32 = a[0] as i32 + a[1] as i32;
println!("{}", x);
}
我只是想從枚舉類型的數組訪問單個值。
爲什麼downvote?請解釋它是一個好主意。 – Boiethios
我沒有倒下,但長期用戶很少解釋downvotes,因爲他們經歷了生氣的OPs報復和投票報復。我認爲大多數人都贊成異或評論。 – Shepmaster
你確定它是'(grid [i] [0])+ grid [i] [1] + grid [i] [2]/3',而不是'(grid [i] [0] + grid [i ] [1] + grid [i] [2])/ 3'? – kennytm