美文网首页
Rust 编程语言-1-Hello World

Rust 编程语言-1-Hello World

作者: onemoremile | 来源:发表于2022-01-05 21:49 被阅读0次

Rust官方推荐的三个学习网站之 The Rust Programming Language

全书共20个章节,下面归纳各个章节的核心内容

1.hello world

1.1 安装rust环境

  • 安装rust
$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
  • 查看版本
$ rustc --version
  • 更新
rustup update
  • rustup doc 启动后本地浏览器看文档
  • nightly

1.2 第一个rust程序

fn main() {
    println!("Hello, world!");
}

编译,然后执行

$ rustc main.rs
$ ./main
Hello, world!

1.3 Cargo

Rust的编译系统和包管理工具,类比为nodejs下的npm/yarn,java下的maven

  • 创建一个项目 cargo new project_name
  • cargo build
  • cargo run
  • Cargo.toml 类比Java Maven项目中的pom.xml

相关文章

网友评论

      本文标题:Rust 编程语言-1-Hello World

      本文链接:https://www.haomeiwen.com/subject/cpikcrtx.html