# rust

# 开始

# 安装

安装rust,重启命令行生效

curl https://sh.rustup.rs -sSf | sh

# 更新

rustup update

# 查看版本

 rustc --version

# hello world

# 基础方式

创建rs文件 main.rs

fn main() {
  println!("Hello, world!");
}

编译 main.rs

rustc main.rs

执行编译得到的文件 main

./main

# cargo 方式

创建

cargo new hello_cargo --bin

构建运行,分两步的

cargo build
./target/debug/hello_cargo

cargo直接构建执行

cargo run

可以使用 cargo buildcargo check 构建项目。 可以使用 cargo run 一步构建并运行项目。

发布(release)构建

使用 cargo build --release 优化编译项目

lastUpdate: 11/29/2021, 1:23:51 AM