變數

Rust provides type safety via static typing. Variable bindings are made with let:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Speaker Notes

This slide should take about 5 minutes.
  • 取消註解 x = 20,證明變數預設為不可變動。如要允許變更,請加入 mut 關鍵字。

  • 這裡的 i32 是變數型別。這是編譯器必須在編譯期間掌握的資訊,但透過型別推斷 (稍後會說明),程式設計師在許多情況下都能省略其型別宣告。