簡體   English   中英

在 rust 中,如何聲明 3 struct 類型數組的別名?

[英]In rust, how to declare an alias of type array of 3 struct?

pub struct Cell {
    coord: Coord,
    content: ValidMoves,
}

如何將“類型”(類型、枚舉、結構)聲明為 3 個Cell的數組?

就像是

pub type Row: [Cell, 3] = [ Cell, Cell, Cell ];

我也試過

pub type Row = [Cell, 3];

解決了 !!

pub type Row = [Cell; 3];

我找到了正確的解決方案閱讀編譯器 output

error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `,`
  --> src\game\structs.rs:56:21
   |
56 | pub type Row = [Cell, 3];
   |                     ^ expected one of 7 possible tokens

並重新閱讀文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM