编写 Rust 程序
1.程序文件后缀名: rs
2.文件命名规范:hello_world.rs
3.(例子)
使用命令创建项目,命名为"hello world"
打开 cmd
输入:
mkdir hello_world
cd hello_world
新建文件
main.rs
![](https://i-blog.csdnimg.cn/direct/ec1870a88d09459793fe9b4991b6b842.png)
编译与运行 Rust 程序
1.编译:rustc main.rs,内容:
fn main() {
println!("Hello World!");
}
![](https://i-blog.csdnimg.cn/direct/88322d882f014a53b95c9062091c633f.png)
![](https://i-blog.csdnimg.cn/direct/b2603afd0b3145329e665896477cff91.png)
2.运行:
2.1.Windows: .\main.exe
2.2.Linux/mac: ./main
![](https://i-blog.csdnimg.cn/direct/1a0873de9acc4ad7a23d2aee32b1e27d.png)