最近一直在被安利Rust,诸如
- 运行速度极快
- 更快的调试和测试
- 安全的内存和更少的垃圾
- 等等…
所以手痒“入坑”Rust,感受一下Rust的魅力~
安装
前往官网下载Rust安装
在VSCode中开发
Rust在VSCode中的拓展名为rust-analyzer,安装后可以获得代码提示和相关功能
创建项目
在终端中输入cargo new hello_world
即可创建项目目录,main.rs
文件在src
中
编译
在终端中输入cargo build
即可编译Rust项目,打包出来的文件在target
文件夹中
运行
在终端中输入cargo run
即可运行编译后的文件,或者在终端中运行.\target\debug\hello_world.exe
文件也能得到同样的结果