从零开始学习Rust。

  1. Rust的安装

略。

  1. Rust版Hello World

fn main() {
    println!("hello world");
}

main函数是程序入口。println!中的!表示这是一个宏。

This is calling a Rust macro, which is how metaprogramming is done in Rust.

  1. Cargo

Cargo is a tool that Rustaceans use to help manage their Rust projects.

Cargo manages three things:

  1. building your code,
  2. downloading the dependencies your code needs,
  3. building those dependencies.

类似于Maven?

构建脚本文件名:Cargo.toml。语法参考:toml-lang/toml

命令:cargo build, cargo run, cargo new xxx(创建新项目, 会自动创建git仓库(.git和.gitignore))。