Day 3:安裝 Rust

學習目標

  • 成功安裝 Rust 工具鏈
  • 驗證安裝是否成功
  • 熟悉終端操作的基本流程

今日重點

安裝(macOS / Linux / WSL)

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Windows:直接下載執行 rustup-init.exe,或使用 winget 安裝。

驗證安裝

rustc --version   # 例:rustc 1.80.0 (xxx 2024-xx-xx)
cargo --version   # 例:cargo 1.80.0

更新與解除安裝

rustup update                 # 更新到最新版
rustup self uninstall         # 解除安裝
rustup component add rustfmt # 補裝格式化工具

練習

  1. 執行安裝指令並確認 rustc --version 有輸出。
  2. 確認 cargo --version 有輸出。
  3. 複習:搜尋你作業系統的官方安裝方式(Windows / macOS / Linux 各不同)。

自我檢查

  • rustc --version 能正常輸出
  • cargo --version 能正常輸出
  • 知道怎麼更新 Rust(rustup update)