Comprehensive Rust(繁体中文) 202406. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 64 Future 控制流程 330 64.1 加入 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 64.2 選取 . . . i32 = 10; println!("x: {x}"); // x = 20; // println!("x: {x}"); } • 取消註解 x = 20,證明變數預設為不可變動。如要允許變更,請加入 mut 關鍵字。 • 這裡的 i32 是變數型別。這是編譯器必須在編譯期間掌握的資訊,但透過型別推斷 (稍後會說明), 程式設計師在許多情況下都能省略其型別宣告。 5.3 值 以下列出一些基 output, but arrays only implement the debug output. This means that we must use debug output here. • 加入 # (例如 {a:#?}) 可叫用方便閱讀的「美化排版」格式。 37 8.2 元組 fn main() { let t: (i8, bool) = (7, true); println!("t0 码力 | 356 页 | 1.41 MB | 1 年前3
共 1 条
- 1













