Rust 并没有一个与->等效的运算符;相反,Rust 有一个叫 自动引用和解引用(automatic referencing and dereferencing)的功能。方法调用是 Rust 中少数几个拥有这种行为的地方。 它是这样工作的:当使用object.something()调用方法时,Rust 会自动为 object 添加&、&mut或*以便使 object 与方法签名匹配。也就是说,这...
Rust 提供了将包分成多个 crate,将 crate 分成模块,以及通过指定绝对或相对路径从一个模块引用另一个模块中定义的项的方式。你可以通过使用 use 语句将路径引入作用域,这样在多次使用时可以使用更短的路径。模块定义的代码默认是私有的,不过可以选择增加 pub 关键字使其定义变为公有。
Rust 知道我们没有覆盖所有可能的情况甚至知道哪些模式被忘记了!Rust 中的匹配是穷举式的(exhaustive):必须穷举到最后的可能性来使代码有效。特别的在这个 Option<T> 的例子中,Rust 防止我们忘记明确的处理 None 的情况,这让我们免于假设拥有一个实际上为空的值,从而使之前提到的价值亿万的错误不可能发生。 我们看...
Rust 的字符类型大小为 4 个字节,表示的是一个 Unicode 标量值,这意味着它可以表示的远远不止是 ASCII。标音字母,中文/日文/韩文的文字,emoji,还有零宽空格(zero width space)在 Rust 中都是合法的字符类型。Unicode 值的范围为 U+0000 ~ U+D7FF 和 U+E000~U+10FFFF。不过“字符”并不是 Unicode 中的...
The Rust Programming Language 中译本 配套材料:Rust By Example 中译本第零~二章 Rust 入门 个人收集的几个国内比较流行的中文社区: rust-lang-cn:Rust 中文官网提到的“非官方翻译”由此组织提供,维护了目前最全的 中文Wiki; rustcc:维护了中文社区的 github.com/rustcc/aweso,翻译了 Rust Atomics and Locks...
Rust A language empowering everyone to build reliable and efficient software. Get Started Version 1.86.0 Why Rust? Performance Rust is blazingly fast and memory-efficient: with no runtime or garbage collector, it can power performance-critical services, run on embedded devices, and easily integrate...
Rust A language empowering everyone to build reliable and efficient software. Get Started Version 1.86.0 Why Rust? Performance Rust is blazingly fast and memory-efficient: with no runtime or garbage collector, it can power performance-critical services, run on embedded devices, and easily integrate...
Rust's ownership system and borrowing make these implementations unique. Feel free to explore more and build upon these examples as you delve deeper into Rust. Remember to check for any updates or changes to the language and libraries, as Rust is actively developed. Rust's ownership system and...
《计算机编程语言 英文原版 The Rust Programming Language Rust权威指南 第二版Steve Klabnik 英文版 进口英语原版书籍》,作者:计算机编程语言 英文原版 The Rust Programming Language Rust权威指南 第二版Steve Klabnik 英文版 进口英语原版书籍Steve 著,出版社:No,I
A crate is the smallest amount of code that the Rust compiler considers at a time. Two types of crates: Binary Crates Binary crates are programs you can compile to an executable that you can run, such as a command-line program or a server. Contains a main function Library Crates 4. ...