自学内容网 自学内容网

Rust入门-Hello World

1、安装

LinuxmacOS 上安装 rustup

打开终端并输入下面命令:

$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

如果安装成功,将出现下面这行:

Rust is installed now. Great!

2、更新

$ rustup self uninstall

3、卸载

$ rustup self uninstall

4、检查安装是否成功

$ rustc -V
rustc 1.56.1 (59eed8a2a 2021-11-01)

$ cargo -V
cargo 1.57.0 (b2e52d7ca 2021-10-21)

5、创建和运行第一个程序 Hello World

(1)创建一个新项目,cargo是Rust的包管理工具

$ cargo new world_hello
$ cd world_hello

(2)运行项目

(base) guilinhuang@GuilindeMacBook-Pro world_hello % cargo run         
   Compiling world_hello v0.1.0 (/Users/guilinhuang/Desktop/RustProject/world_hello)
    Finished dev [unoptimized + debuginfo] target(s) in 0.83s
     Running `target/debug/world_hello`
Hello, world!

看到Hello world!就大功告成啦

千里之行,始于足下,加油!


原文地址:https://blog.csdn.net/vince1998/article/details/137838562

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!