使用rust编写helloworld项目

Posted 天界程序员

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用rust编写helloworld项目相关的知识,希望对你有一定的参考价值。

1、新建一个文件目录

mkdir hello_world

然后进入hello_world 文件目录里面

cd hello_world

2、新建main.rs文件并编写代码

fn main() 
    println!("Hello,world!")

编写好以上代码,保存后,我们使用rustc命令编译该代码

rustc main.rs

执行完以上代码后项目目录会多出两个文件:main.exemain.pdb

我们这里执行main.exe文件

.\\main.exe

可以看到打印结果是:Hello,world! , 这就是我们想要的。

以上是关于使用rust编写helloworld项目的主要内容,如果未能解决你的问题,请参考以下文章