01|环境搭建与helloworld程序

本篇主要介绍rust安装与hello world程序的编写

安装

curl https://sh.rustup.rs | sh

运行上面命令,选择1安装方式,会在$HOME/.cargo/bin下面安装rustc、cargo、rustup等工具命令。

  • rustc是rust语言编译器,把源文件编译成二进制可执行文件
  • cargo是是rust项目管理工具
  • rustup是rust工具链

hello world程序

hello.rs

fn main() {
    println!("hello world!");
}

编译

rustc hello.rs

运行

./hello

解析说明

  • fn是定义一个函数,这里我们定义一个main函数
  • println!是一个宏,用于打印输出
点赞 0
收藏 0
分享
本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
billchen-818
billchen-818
0x5652...DbDE
江湖只有他的大名,没有他的介绍。