rust入坑小记-01-安装与环境
一、安装和配置
rust安装(linux)
1 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh |
cargo创建项目
1 | cargo new hello_world |
cargo创建的项目分为:
bin项目:可直接运行的二进制项目lib项目:库类型项目,不可以直接运行,而是作为第三方库被引用
当我们使用cargo new project时,默认创建的项目为bin项目。
helloworld
约定俗成地,需要写一个helloworld:
1 | fn main() { |
入口
以cargo创建的bin项目入口为src/main.rs内的main函数。
1 | fn main() { |
在项目根目录使用cargo run即可运行项目。
二、rust基础篇
本博客所有文章除特别声明外,均采用 CC BY-NC-ND 4.0 许可协议。转载请注明来自 Black Flies!
评论