使用vsCode创建demo1项目,创建hellow_word.rs文件
需要注意的:
1:rust文件以.rs结尾
2:main是特殊函数,每个rust程序的入口,就想java中的main函数一样
3:rust的缩进是四个空格而不是tab键
4:println!()是宏
二 编译
在终端进入项目根目录,执行rustc命令
rustc hellow_word.rs
编译后就会生成一个可执行文件
三 执行可执行文件
mac/Linux 命令:./hellow_word
windows下执行命令:.\hellow_word.exe
成功输出
最后:rustc只适合简单的rust程序,复杂的rust程序使用cargo