Rust学习笔记
学习资料
📚书单

- Rust For Rustaceans
- The Rust Programming Language, 2nd Edition
- Programming Rust, 2nd Edition
- Creative Projects for Rust Programmers
官方资料
The Rust Programming Language - The Rust Programming Language (rust-lang.org)
Rust 语言圣经 - Rust语言圣经(Rust Course)
关于 pracitce.rs - Rust By Practice( Rust 练习实践 )
进阶 - Rust 秘典(死灵书) (purewhite.io)
其他
- Rust Playground
- rust-lang/rustlings: Small exercises to get you used to reading and writing Rust code! (github.com)
- async_task - Rust (docs.rs)
- smol/examples at master · smol-rs/smol (github.com)
安装
curl https://sh.rustup.rs -sSf | sh
rustc
Hello World
Tab:用4个空格替换;
分号:可要可不要,但 Rust 风格是需要;
代码文件命名:用下划线分割不同单词;
fn main() {
println!("hello world!")
}
编译与运行
rustc main.rs
./main
cargo
使用cargo比rustc的优势
- 依赖管理
- 编译大型项目
常用命令
- cargo new
- cargo build
- cargo run
- cargo check