Rust-Book Getting Started
从零开始学习Rust。
-
Rust的安装
略。
-
Rust版Hello World
fn main() {
println!("hello world");
}
main
函数是程序入口。println!
中的!
表示这是一个宏。
This is calling a Rust macro, which is how metaprogramming is done in Rust.
-
Cargo
Cargo is a tool that Rustaceans use to help manage their Rust projects.
Cargo manages three things:
- building your code,
- downloading the dependencies your code needs,
- building those dependencies.
类似于Maven?
构建脚本文件名:Cargo.toml
。语法参考:toml-lang/toml。
命令:cargo build
, cargo run
, cargo new xxx
(创建新项目, 会自动创建git仓库(.git和.gitignore))。