0
点赞
收藏
分享

微信扫一扫

Rust语言基础


安装 Rust

  • 官网:https://www.rust-lang.org/
  • Linux or Mac:
  • curl https://rustup.rs -sSf | sh
  • Windows: 按官网指示操作
  • Windows Subsystem for Linux:
  • curl --proto ‘=https’ --tlsv1.2 -sSf https://sh.rustup.rs | sh

查看是否安装成功

​rustc --version​

Rust语言基础_Rust

更新与卸载 Rust

  • 更新 Rust
  • rustup update
  • 卸载 Rust
  • rustup self uninstall

本地文档

  • 安装Rust时,会在本地安装文档,可离线浏览
  • 运行​​rustup doc​​可在浏览器打开本地文档

开发工具

  • Visual Studio Code
  • Rust 插件
  • Clion(Intellij Idea 系列)
  • Rust 插件

Hello World

新建文件夹 ​​mkdir hello_world​​​ 进入文件夹 ​​cd h*​​ 使用 VS Code 打开 ​​code .​

编写 Rust 程序

  • 程序文件后缀名:rs
  • 文件命名规范:hello_world.rs

fn main(){
println!("Hello World");
}

编译与运行 Rust 程序

  • 编译:rustc main.rs
    编译成功了!

    可以看到VS Code 下多了两个文件,分别是main.exe和main.pdb。
  • 运行:
  • Windows:.\main.exe
  • Linux/mac:./main


举报

相关推荐

0 条评论