Rust 基礎大綱
- 1.Summary
- 安裝
- 教材
- 2 Rust 源
1.Summary
安裝
https://www.rust-lang.org/zh-CN/tools/install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh# 安裝完成后,驗證是否成功
rustc -V
cargo -V# 創建項目
cargo new my_project
# 編譯項目
cargo build
# 生成的可執行文件位于 target/debug/ 目錄下。# 運行程序
# 直接運行以下命令:
cargo run
教材
- 英文:https://doc.rust-lang.org/book/
- Can also open it locally: rustup docs --book
- 中文:https://kaisery.github.io/trpl-zh-cn/title-page.html
rust by practice
https://practice.rs/
rust by examples
https://doc.rust-lang.org/stable/rust-by-example/
rust 圣經
https://course.rs/about-book.html
rust 官方文檔中文網站
https://rustwiki.org/
Experiment: Improving the Rust Book
https://rust-book.cs.brown.edu/
2 Rust 源
中國區,可能連接 crates.io 會有問題。
- https://mirrors.ustc.edu.cn/help/crates.io-index.html
在 $HOME/.cargo/config
中添加如下內容:
[source.crates-io]
replace-with = 'ustc'[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
如果所處的環境中不允許使用 git 協議,可以把上述地址改為:
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
2.1 cargo 版本>= 1.68 支持稀疏索引
可以在 $HOME/.cargo/config
中添加如下內容:
cargo 1.68 版本開始支持稀疏索引:不再需要完整克隆 crates.io-index 倉庫,可以加快獲取包的速度。
[source.crates-io]
replace-with = 'ustc'[source.ustc]
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io-index/"