美文网首页
rust 学习 笔记(一)

rust 学习 笔记(一)

作者: 流血的手指 | 来源:发表于2019-02-27 14:22 被阅读1次

1. 打开本地的rust 文档

rustup doc
里面有 install 等 各类详细信息,就不多详述了。

2. cargo

cargo new proj_name
cargo build
cargo build --release  # release 版本
cargo run
cargo check
cargo update  # 升级库的版本,只升级小版本
cargo doc --open   # 查看库(crate)的文档

3. const

const MAX_POINTS: u32 = 100_000;

变量名大写+下划线,下划线可以加到数字中,提高可读性?

shadow & mut

Shadowing is different than marking a variable as mut, because we’ll get a compile-time error if we accidentally try to reassign to this variable without using the let keyword. By using let, we can perform a few transformations on a value but have the variable be immutable after those transformations have been completed.

The other difference between mut and shadowing is that because we’re effectively creating a new variable when we use the let keyword again, we can change the type of the value but reuse the same name. For example, say our program asks a user to show how many spaces they want between some text by inputting space characters, but we really want to store that input as a number:

相关文章

  • Rust学习笔记(一)

    第一步要做的事情是 安装Rust编译环境(人人都有的windows) 咱工作机器是win7+mingw所以直接到下...

  • rust 学习 笔记(一)

    1. 打开本地的rust 文档 rustup doc里面有 install 等 各类详细信息,就不多详述了。 2....

  • rust学习笔记

    Cargo:Rust 的构建工具和包管理器 您在安装 Rustup 时,也会安装 Rust 构建工具和包管理器的最...

  • 2.Rust新手教程-数据类型

    学习笔记,仅此而已 Rust是静态编译语言,在编译时必须知道所有变量的类型,其中Rust内部有2套机制 基于定义的...

  • Rust学习笔记-01

    0. Rust的源文件 像c语言的源文件我们以".c"为后缀,c++以".cpp"为后缀,java以".java"...

  • [学习笔记]初试rust

    什么是Rust? Rust 是一门系统级编程语言,可以被归纳为通用的、多范式、编译型语言,与C/C++不同的是,R...

  • Rust 学习笔记 - 安装

    在 Linux 和 Mac 上安装 如果使用 Linux 或 Mac, 最简单的做法就是打开一个终端并输入: 这将...

  • Rust 学习笔记 - 函数

    Rust 是一门多范式的编程语言,但 Rust 的编程风格是更偏向于函数式的,函数在 Rust 中是“一等公民”。...

  • Rust学习笔记(3)

    内容整理自:https://doc.rust-lang.org/book/title-page.html Chap...

  • Rust 学习笔记-序

    github地址:https://github.com/bradyjoestar/rustnotes(欢迎star...

网友评论

      本文标题:rust 学习 笔记(一)

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