{"doc_urls":["title-page.html#rust-程序设计语言","foreword.html#前言","ch00-00-introduction.html#简介","ch00-00-introduction.html#rust-适合哪些人","ch00-00-introduction.html#开发者团队","ch00-00-introduction.html#学生","ch00-00-introduction.html#公司","ch00-00-introduction.html#开源开发者","ch00-00-introduction.html#重视速度和稳定性的开发者","ch00-00-introduction.html#本书适合哪些人","ch00-00-introduction.html#如何阅读本书","ch00-00-introduction.html#源代码","ch01-00-getting-started.html#入门指南","ch01-01-installation.html#安装","ch01-01-installation.html#命令行标记","ch01-01-installation.html#在-linux-或-macos-上安装-rustup","ch01-01-installation.html#在-windows-上安装-rustup","ch01-01-installation.html#故障排除troubleshooting","ch01-01-installation.html#更新与卸载","ch01-01-installation.html#本地文档","ch01-02-hello-world.html#hello-world","ch01-02-hello-world.html#创建项目目录","ch01-02-hello-world.html#编写并运行-rust-程序","ch01-02-hello-world.html#分析这个-rust-程序","ch01-02-hello-world.html#编译和运行是彼此独立的步骤","ch01-03-hello-cargo.html#hello-cargo","ch01-03-hello-cargo.html#使用-cargo-创建项目","ch01-03-hello-cargo.html#构建并运行-cargo-项目","ch01-03-hello-cargo.html#发布release构建","ch01-03-hello-cargo.html#把-cargo-当作习惯","ch01-03-hello-cargo.html#总结","ch02-00-guessing-game-tutorial.html#写个猜数字游戏","ch02-00-guessing-game-tutorial.html#准备一个新项目","ch02-00-guessing-game-tutorial.html#处理一次猜测","ch02-00-guessing-game-tutorial.html#使用变量储存值","ch02-00-guessing-game-tutorial.html#接收用户输入","ch02-00-guessing-game-tutorial.html#使用-result-类型来处理潜在的错误","ch02-00-guessing-game-tutorial.html#使用-println-占位符打印值","ch02-00-guessing-game-tutorial.html#测试第一部分代码","ch02-00-guessing-game-tutorial.html#生成一个秘密数字","ch02-00-guessing-game-tutorial.html#使用-crate-来增加更多功能","ch02-00-guessing-game-tutorial.html#生成一个随机数","ch02-00-guessing-game-tutorial.html#比较猜测的数字和秘密数字","ch02-00-guessing-game-tutorial.html#使用循环来允许多次猜测","ch02-00-guessing-game-tutorial.html#猜测正确后退出","ch02-00-guessing-game-tutorial.html#处理无效输入","ch02-00-guessing-game-tutorial.html#总结","ch03-00-common-programming-concepts.html#常见编程概念","ch03-00-common-programming-concepts.html#关键字","ch03-01-variables-and-mutability.html#变量和可变性","ch03-01-variables-and-mutability.html#常量","ch03-01-variables-and-mutability.html#隐藏","ch03-02-data-types.html#数据类型","ch03-02-data-types.html#标量类型","ch03-02-data-types.html#复合类型","ch03-03-how-functions-work.html#函数","ch03-03-how-functions-work.html#参数","ch03-03-how-functions-work.html#语句和表达式","ch03-03-how-functions-work.html#具有返回值的函数","ch03-04-comments.html#注释","ch03-05-control-flow.html#控制流","ch03-05-control-flow.html#if-表达式","ch03-05-control-flow.html#使用循环重复执行","ch03-05-control-flow.html#总结","ch04-00-understanding-ownership.html#认识所有权","ch04-01-what-is-ownership.html#什么是所有权","ch04-01-what-is-ownership.html#栈stack与堆heap","ch04-01-what-is-ownership.html#所有权规则","ch04-01-what-is-ownership.html#变量作用域","ch04-01-what-is-ownership.html#string-类型","ch04-01-what-is-ownership.html#内存与分配","ch04-01-what-is-ownership.html#所有权与函数","ch04-01-what-is-ownership.html#返回值与作用域","ch04-02-references-and-borrowing.html#引用与借用","ch04-02-references-and-borrowing.html#可变引用","ch04-02-references-and-borrowing.html#悬垂引用dangling-references","ch04-02-references-and-borrowing.html#引用的规则","ch04-03-slices.html#slice-类型","ch04-03-slices.html#字符串-slice","ch04-03-slices.html#其他类型的-slice","ch04-03-slices.html#总结","ch05-00-structs.html#使用结构体组织相关联的数据","ch05-01-defining-structs.html#结构体的定义和实例化","ch05-01-defining-structs.html#使用字段初始化简写语法","ch05-01-defining-structs.html#使用结构体更新语法从其他实例创建实例","ch05-01-defining-structs.html#使用没有命名字段的元组结构体来创建不同的类型","ch05-01-defining-structs.html#没有任何字段的类单元结构体","ch05-01-defining-structs.html#结构体数据的所有权","ch05-02-example-structs.html#结构体示例程序","ch05-02-example-structs.html#使用元组重构","ch05-02-example-structs.html#使用结构体重构赋予更多意义","ch05-02-example-structs.html#通过派生-trait-增加实用功能","ch05-03-method-syntax.html#方法语法","ch05-03-method-syntax.html#定义方法","ch05-03-method-syntax.html#--运算符到哪去了","ch05-03-method-syntax.html#带有更多参数的方法","ch05-03-method-syntax.html#关联函数","ch05-03-method-syntax.html#多个-impl-块","ch05-03-method-syntax.html#总结","ch06-00-enums.html#枚举和模式匹配","ch06-01-defining-an-enum.html#枚举的定义","ch06-01-defining-an-enum.html#枚举值","ch06-01-defining-an-enum.html#option-枚举和其相对于空值的优势","ch06-02-match.html#match-控制流结构","ch06-02-match.html#绑定值的模式","ch06-02-match.html#匹配-option","ch06-02-match.html#匹配是穷尽的","ch06-02-match.html#通配模式和-_-占位符","ch06-03-if-let.html#if-let-简洁控制流","ch06-03-if-let.html#总结","ch07-00-managing-growing-projects-with-packages-crates-and-modules.html#使用包crate-和模块管理不断增长的项目","ch07-01-packages-and-crates.html#包和-crate","ch07-02-defining-modules-to-control-scope-and-privacy.html#定义模块来控制作用域与私有性","ch07-02-defining-modules-to-control-scope-and-privacy.html#模块小抄","ch07-02-defining-modules-to-control-scope-and-privacy.html#在模块中对相关代码进行分组","ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html#引用模块项目的路径","ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html#使用-pub-关键字暴露路径","ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html#二进制和库-crate-包的最佳实践","ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html#super-开始的相对路径","ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html#创建公有的结构体和枚举","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#使用-use-关键字将路径引入作用域","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#创建惯用的-use-路径","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#使用-as-关键字提供新的名称","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#使用-pub-use-重导出名称","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#使用外部包","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#嵌套路径来消除大量的-use-行","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#通过-glob-运算符将所有的公有定义引入作用域","ch07-05-separating-modules-into-different-files.html#将模块拆分成多个文件","ch07-05-separating-modules-into-different-files.html#另一种文件路径","ch07-05-separating-modules-into-different-files.html#总结","ch08-00-common-collections.html#常见集合","ch08-01-vectors.html#使用-vector-储存列表","ch08-01-vectors.html#新建-vector","ch08-01-vectors.html#更新-vector","ch08-01-vectors.html#读取-vector-的元素","ch08-01-vectors.html#遍历-vector-中的元素","ch08-01-vectors.html#使用枚举来储存多种类型","ch08-01-vectors.html#丢弃-vector-时也会丢弃其所有元素","ch08-02-strings.html#使用字符串储存-utf-8-编码的文本","ch08-02-strings.html#什么是字符串","ch08-02-strings.html#新建字符串","ch08-02-strings.html#更新字符串","ch08-02-strings.html#索引字符串","ch08-02-strings.html#字符串-slice","ch08-02-strings.html#遍历字符串的方法","ch08-02-strings.html#字符串并不简单","ch08-03-hash-maps.html#使用-hash-map-储存键值对","ch08-03-hash-maps.html#新建一个哈希-map","ch08-03-hash-maps.html#访问哈希-map-中的值","ch08-03-hash-maps.html#哈希-map-和所有权","ch08-03-hash-maps.html#更新哈希-map","ch08-03-hash-maps.html#哈希函数","ch08-03-hash-maps.html#总结","ch09-00-error-handling.html#错误处理","ch09-01-unrecoverable-errors-with-panic.html#用-panic-处理不可恢复的错误","ch09-01-unrecoverable-errors-with-panic.html#对应-panic-时的栈展开或终止","ch09-01-unrecoverable-errors-with-panic.html#使用-panic-的-backtrace","ch09-02-recoverable-errors-with-result.html#用-result-处理可恢复的错误","ch09-02-recoverable-errors-with-result.html#匹配不同的错误","ch09-02-recoverable-errors-with-result.html#失败时-panic-的简写unwrap-和-expect","ch09-02-recoverable-errors-with-result.html#传播错误","ch09-02-recoverable-errors-with-result.html#传播错误的简写-运算符","ch09-02-recoverable-errors-with-result.html#哪里可以使用--运算符","ch09-03-to-panic-or-not-to-panic.html#要不要-panic","ch09-03-to-panic-or-not-to-panic.html#示例代码原型和测试都非常适合-panic","ch09-03-to-panic-or-not-to-panic.html#当我们比编译器知道更多的情况","ch09-03-to-panic-or-not-to-panic.html#错误处理指导原则","ch09-03-to-panic-or-not-to-panic.html#创建自定义类型进行有效性验证","ch09-03-to-panic-or-not-to-panic.html#总结","ch10-00-generics.html#泛型trait-和生命周期","ch10-00-generics.html#提取函数来减少重复","ch10-01-syntax.html#泛型数据类型","ch10-01-syntax.html#在函数定义中使用泛型","ch10-01-syntax.html#结构体定义中的泛型","ch10-01-syntax.html#枚举定义中的泛型","ch10-01-syntax.html#方法定义中的泛型","ch10-01-syntax.html#泛型代码的性能","ch10-02-traits.html#trait定义共同行为","ch10-02-traits.html#定义-trait","ch10-02-traits.html#为类型实现-trait","ch10-02-traits.html#默认实现","ch10-02-traits.html#trait-作为参数","ch10-02-traits.html#返回实现了-trait-的类型","ch10-02-traits.html#使用-trait-bound-有条件地实现方法","ch10-03-lifetime-syntax.html#生命周期确保引用有效","ch10-03-lifetime-syntax.html#生命周期避免了悬垂引用","ch10-03-lifetime-syntax.html#函数中的泛型生命周期","ch10-03-lifetime-syntax.html#生命周期注解语法","ch10-03-lifetime-syntax.html#函数签名中的生命周期注解","ch10-03-lifetime-syntax.html#深入理解生命周期","ch10-03-lifetime-syntax.html#结构体定义中的生命周期注解","ch10-03-lifetime-syntax.html#生命周期省略lifetime-elision","ch10-03-lifetime-syntax.html#方法定义中的生命周期注解","ch10-03-lifetime-syntax.html#静态生命周期","ch10-03-lifetime-syntax.html#结合泛型类型参数trait-bounds-和生命周期","ch10-03-lifetime-syntax.html#总结","ch11-00-testing.html#编写自动化测试","ch11-01-writing-tests.html#如何编写测试","ch11-01-writing-tests.html#测试函数剖析","ch11-01-writing-tests.html#使用-assert-宏来检查结果","ch11-01-writing-tests.html#使用-assert_eq-和-assert_ne-宏来测试相等","ch11-01-writing-tests.html#自定义失败信息","ch11-01-writing-tests.html#使用-should_panic-检查-panic","ch11-01-writing-tests.html#将-result-用于测试","ch11-02-running-tests.html#控制测试如何运行","ch11-02-running-tests.html#并行或连续的运行测试","ch11-02-running-tests.html#显示函数输出","ch11-02-running-tests.html#通过指定名字来运行部分测试","ch11-02-running-tests.html#除非特别指定否则忽略某些测试","ch11-03-test-organization.html#测试的组织结构","ch11-03-test-organization.html#单元测试","ch11-03-test-organization.html#集成测试","ch11-03-test-organization.html#总结","ch12-00-an-io-project.html#一个-io-项目构建一个命令行程序","ch12-01-accepting-command-line-arguments.html#接受命令行参数","ch12-01-accepting-command-line-arguments.html#读取参数值","ch12-01-accepting-command-line-arguments.html#args-函数和无效的-unicode","ch12-01-accepting-command-line-arguments.html#将参数值保存进变量","ch12-02-reading-a-file.html#读取文件","ch12-03-improving-error-handling-and-modularity.html#重构改进模块性和错误处理","ch12-03-improving-error-handling-and-modularity.html#二进制项目的关注分离","ch12-03-improving-error-handling-and-modularity.html#提取参数解析器","ch12-03-improving-error-handling-and-modularity.html#组合配置值","ch12-03-improving-error-handling-and-modularity.html#创建一个-config-的构造函数","ch12-03-improving-error-handling-and-modularity.html#修复错误处理","ch12-03-improving-error-handling-and-modularity.html#从-main-提取逻辑","ch12-03-improving-error-handling-and-modularity.html#将代码拆分到库-crate","ch12-04-testing-the-librarys-functionality.html#采用测试驱动开发完善库的功能","ch12-04-testing-the-librarys-functionality.html#编写失败测试","ch12-04-testing-the-librarys-functionality.html#编写使测试通过的代码","ch12-05-working-with-environment-variables.html#处理环境变量","ch12-05-working-with-environment-variables.html#编写一个大小写不敏感-search-函数的失败测试","ch12-05-working-with-environment-variables.html#实现-search_case_insensitive-函数","ch12-06-writing-to-stderr-instead-of-stdout.html#将错误信息输出到标准错误而不是标准输出","ch12-06-writing-to-stderr-instead-of-stdout.html#检查错误应该写入何处","ch12-06-writing-to-stderr-instead-of-stdout.html#将错误打印到标准错误","ch12-06-writing-to-stderr-instead-of-stdout.html#总结","ch13-00-functional-features.html#rust-中的函数式语言功能迭代器与闭包","ch13-01-closures.html#闭包可以捕获环境的匿名函数","ch13-01-closures.html#闭包会捕获其环境","ch13-01-closures.html#闭包类型推断和注解","ch13-01-closures.html#捕获引用或者移动所有权","ch13-01-closures.html#将被捕获的值移出闭包和-fn-trait","ch13-02-iterators.html#使用迭代器处理元素序列","ch13-02-iterators.html#iterator-trait-和-next-方法","ch13-02-iterators.html#消费迭代器的方法","ch13-02-iterators.html#产生其他迭代器的方法","ch13-02-iterators.html#使用捕获其环境的闭包","ch13-03-improving-our-io-project.html#改进-io-项目","ch13-03-improving-our-io-project.html#使用迭代器去除-clone","ch13-03-improving-our-io-project.html#使用迭代器适配器来使代码更简明","ch13-03-improving-our-io-project.html#选择循环或迭代器","ch13-04-performance.html#性能对比循环-vs-迭代器","ch13-04-performance.html#总结","ch14-00-more-about-cargo.html#进一步认识-cargo-和-cratesio","ch14-01-release-profiles.html#采用发布配置自定义构建","ch14-02-publishing-to-crates-io.html#将-crate-发布到-cratesio","ch14-02-publishing-to-crates-io.html#编写有用的文档注释","ch14-02-publishing-to-crates-io.html#使用-pub-use-导出合适的公有-api","ch14-02-publishing-to-crates-io.html#创建-cratesio-账号","ch14-02-publishing-to-crates-io.html#向新-crate-添加元信息","ch14-02-publishing-to-crates-io.html#发布到-cratesio","ch14-02-publishing-to-crates-io.html#发布现存-crate-的新版本","ch14-02-publishing-to-crates-io.html#使用-cargo-yank-从-cratesio-弃用版本","ch14-03-cargo-workspaces.html#cargo-工作空间","ch14-03-cargo-workspaces.html#创建工作空间","ch14-03-cargo-workspaces.html#在工作空间中创建第二个包","ch14-04-installing-binaries.html#使用-cargo-install-安装二进制文件","ch14-05-extending-cargo.html#cargo-自定义扩展命令","ch14-05-extending-cargo.html#总结","ch15-00-smart-pointers.html#智能指针","ch15-01-box.html#使用box指向堆上的数据","ch15-01-box.html#使用-box-在堆上储存数据","ch15-01-box.html#box-允许创建递归类型","ch15-01-box.html#计算非递归类型的大小","ch15-01-box.html#使用-box-给递归类型一个已知的大小","ch15-02-deref.html#通过-deref-trait-将智能指针当作常规引用处理","ch15-02-deref.html#追踪指针的值","ch15-02-deref.html#像引用一样使用-box","ch15-02-deref.html#自定义智能指针","ch15-02-deref.html#通过实现-deref-trait-将某类型像引用一样处理","ch15-02-deref.html#函数和方法的隐式-deref-强制转换","ch15-02-deref.html#deref-强制转换如何与可变性交互","ch15-03-drop.html#使用-drop-trait-运行清理代码","ch15-04-rc.html#rc-引用计数智能指针","ch15-04-rc.html#使用-rc-共享数据","ch15-04-rc.html#克隆-rc-会增加引用计数","ch15-05-interior-mutability.html#refcell-和内部可变性模式","ch15-05-interior-mutability.html#通过-refcell-在运行时检查借用规则","ch15-05-interior-mutability.html#内部可变性不可变值的可变借用","ch15-05-interior-mutability.html#refcell-在运行时记录借用","ch15-05-interior-mutability.html#结合-rc-和-refcell-来拥有多个可变数据所有者","ch15-06-reference-cycles.html#引用循环与内存泄漏","ch15-06-reference-cycles.html#制造引用循环","ch15-06-reference-cycles.html#避免引用循环将-rc-变为-weak","ch15-06-reference-cycles.html#总结","ch16-00-concurrency.html#无畏并发","ch16-01-threads.html#使用线程同时运行代码","ch16-01-threads.html#使用-spawn-创建新线程","ch16-01-threads.html#将-move-闭包与线程一同使用","ch16-02-message-passing.html#使用消息传递在线程间传送数据","ch16-02-message-passing.html#信道与所有权转移","ch16-02-message-passing.html#发送多个值并观察接收者的等待","ch16-02-message-passing.html#通过克隆发送者来创建多个生产者","ch16-03-shared-state.html#共享状态的并发","ch16-03-shared-state.html#使用互斥器实现同一时刻只允许一个线程访问数据","ch16-03-shared-state.html#mutex的-api","ch16-03-shared-state.html#refcellrc-与-mutexarc-的相似性","ch16-04-extensible-concurrency-sync-and-send.html#使用-sync-和-send-trait-的可扩展并发","ch16-04-extensible-concurrency-sync-and-send.html#通过-send-允许在线程间转移所有权","ch16-04-extensible-concurrency-sync-and-send.html#sync-允许多线程访问","ch16-04-extensible-concurrency-sync-and-send.html#手动实现-send-和-sync-是不安全的","ch16-04-extensible-concurrency-sync-and-send.html#总结","ch17-00-async-await.html#async-和-await","ch17-00-async-await.html#并行与并发","ch17-01-futures-and-syntax.html#futures-和-async-语法","ch17-01-futures-and-syntax.html#第一个异步程序","ch17-02-concurrency-with-async.html#并发与-async","ch17-02-concurrency-with-async.html#计数","ch17-02-concurrency-with-async.html#消息传递","ch17-03-more-futures.html#使用任意数量的-futures","ch17-03-more-futures.html#future-竞争","ch17-03-more-futures.html#yielding","ch17-03-more-futures.html#构建我们自己的异步抽象","ch17-04-streams.html#流streams","ch17-05-traits-for-async.html#深入理解-async-相关的-traits","ch17-06-futures-tasks-threads.html#futures任务tasks和线程threads","ch18-00-oop.html#rust-的面向对象特性","ch18-01-what-is-oo.html#面向对象语言的特征","ch18-01-what-is-oo.html#对象包含数据和行为","ch18-01-what-is-oo.html#封装隐藏了实现细节","ch18-01-what-is-oo.html#继承作为类型系统与代码共享","ch18-02-trait-objects.html#顾及不同类型值的-trait-对象","ch18-02-trait-objects.html#定义通用行为的-trait","ch18-02-trait-objects.html#实现-trait","ch18-02-trait-objects.html#trait-对象执行动态分发","ch18-03-oo-design-patterns.html#面向对象设计模式的实现","ch18-03-oo-design-patterns.html#定义-post-并新建一个草案状态的实例","ch18-03-oo-design-patterns.html#存放博文内容的文本","ch18-03-oo-design-patterns.html#确保博文草案的内容是空的","ch18-03-oo-design-patterns.html#请求审核博文来改变其状态","ch18-03-oo-design-patterns.html#增加改变-content-行为的-approve-方法","ch18-03-oo-design-patterns.html#状态模式的权衡取舍","ch18-03-oo-design-patterns.html#总结","ch19-00-patterns.html#模式与模式匹配","ch19-01-all-the-places-for-patterns.html#所有可能会用到模式的位置","ch19-01-all-the-places-for-patterns.html#match-分支","ch19-01-all-the-places-for-patterns.html#if-let-条件表达式","ch19-01-all-the-places-for-patterns.html#while-let-条件循环","ch19-01-all-the-places-for-patterns.html#for-循环","ch19-01-all-the-places-for-patterns.html#let-语句","ch19-01-all-the-places-for-patterns.html#函数参数","ch19-02-refutability.html#refutability可反驳性-模式是否会匹配失效","ch19-03-pattern-syntax.html#所有的模式语法","ch19-03-pattern-syntax.html#匹配字面值","ch19-03-pattern-syntax.html#匹配命名变量","ch19-03-pattern-syntax.html#多个模式","ch19-03-pattern-syntax.html#通过--匹配值的范围","ch19-03-pattern-syntax.html#解构并分解值","ch19-03-pattern-syntax.html#忽略模式中的值","ch19-03-pattern-syntax.html#匹配守卫提供的额外条件","ch19-03-pattern-syntax.html#-绑定","ch19-03-pattern-syntax.html#总结","ch20-00-advanced-features.html#高级特征","ch20-01-unsafe-rust.html#不安全-rust","ch20-01-unsafe-rust.html#不安全的超能力","ch20-01-unsafe-rust.html#解引用裸指针","ch20-01-unsafe-rust.html#调用不安全函数或方法","ch20-01-unsafe-rust.html#访问或修改可变静态变量","ch20-01-unsafe-rust.html#实现不安全-trait","ch20-01-unsafe-rust.html#访问联合体中的字段","ch20-01-unsafe-rust.html#何时使用不安全代码","ch20-03-advanced-traits.html#高级-trait","ch20-03-advanced-traits.html#关联类型在-trait-定义中指定占位符类型","ch20-03-advanced-traits.html#默认泛型类型参数和运算符重载","ch20-03-advanced-traits.html#完全限定语法与消歧义调用相同名称的方法","ch20-03-advanced-traits.html#父-trait-用于在另一个-trait-中使用某-trait-的功能","ch20-03-advanced-traits.html#newtype-模式用以在外部类型上实现外部-trait","ch20-04-advanced-types.html#高级类型","ch20-04-advanced-types.html#为了类型安全和抽象而使用-newtype-模式","ch20-04-advanced-types.html#类型别名用来创建类型同义词","ch20-04-advanced-types.html#从不返回的-never-type","ch20-04-advanced-types.html#动态大小类型和-sized-trait","ch20-05-advanced-functions-and-closures.html#高级函数与闭包","ch20-05-advanced-functions-and-closures.html#函数指针","ch20-05-advanced-functions-and-closures.html#返回闭包","ch20-06-macros.html#宏","ch20-06-macros.html#宏和函数的区别","ch20-06-macros.html#使用-macro_rules-的声明宏用于通用元编程","ch20-06-macros.html#用于从属性生成代码的过程宏","ch20-06-macros.html#如何编写自定义-derive-宏","ch20-06-macros.html#类属性宏","ch20-06-macros.html#类函数宏","ch20-06-macros.html#总结","ch21-00-final-project-a-web-server.html#最后的项目构建多线程-web-server","ch21-01-single-threaded.html#构建单线程-web-server","ch21-01-single-threaded.html#监听-tcp-连接","ch21-01-single-threaded.html#读取请求","ch21-01-single-threaded.html#编写响应","ch21-01-single-threaded.html#返回真正的-html","ch21-01-single-threaded.html#验证请求并有选择的进行响应","ch21-01-single-threaded.html#少量代码重构","ch21-02-multithreaded.html#将单线程-server-变为多线程-server","ch21-02-multithreaded.html#在当前-server-实现中模拟慢请求","ch21-02-multithreaded.html#使用线程池改善吞吐量","ch21-03-graceful-shutdown-and-cleanup.html#优雅停机与清理","ch21-03-graceful-shutdown-and-cleanup.html#为-threadpool-实现-drop-trait","ch21-03-graceful-shutdown-and-cleanup.html#向线程发送信号使其停止接收任务","ch21-03-graceful-shutdown-and-cleanup.html#总结","appendix-00.html#附录","appendix-01-keywords.html#附录-a关键字","appendix-01-keywords.html#目前正在使用的关键字","appendix-01-keywords.html#保留做将来使用的关键字","appendix-01-keywords.html#原始标识符","appendix-02-operators.html#附录-b运算符与符号","appendix-02-operators.html#运算符","appendix-02-operators.html#非运算符符号","appendix-03-derivable-traits.html#附录-c可派生的-trait","appendix-03-derivable-traits.html#用于程序员输出的-debug","appendix-03-derivable-traits.html#等值比较的-partialeq-和-eq","appendix-03-derivable-traits.html#次序比较的-partialord-和-ord","appendix-03-derivable-traits.html#复制值的-clone-和-copy","appendix-03-derivable-traits.html#固定大小的值到值映射的-hash","appendix-03-derivable-traits.html#默认值的-default","appendix-04-useful-development-tools.html#附录-d实用开发工具","appendix-04-useful-development-tools.html#通过-rustfmt-自动格式化","appendix-04-useful-development-tools.html#通过-rustfix-修复代码","appendix-04-useful-development-tools.html#通过-clippy-提供更多-lint-功能","appendix-04-useful-development-tools.html#使用-rust-analyzer-的-ide-集成","appendix-05-editions.html#附录-e版本","appendix-06-translation.html#附录-f本书译本","appendix-07-nightly-rust.html#附录-grust-是如何开发的与-nightly-rust","appendix-07-nightly-rust.html#无停滞稳定","appendix-07-nightly-rust.html#choo-choo-发布通道和发布时刻表riding-the-trains","appendix-07-nightly-rust.html#不稳定功能","appendix-07-nightly-rust.html#rustup-和-rust-nightly-的职责","appendix-07-nightly-rust.html#rfc-过程和团队"],"index":{"documentStore":{"docInfo":{"0":{"body":33,"breadcrumbs":2,"title":1},"1":{"body":22,"breadcrumbs":0,"title":0},"10":{"body":47,"breadcrumbs":0,"title":0},"100":{"body":48,"breadcrumbs":0,"title":0},"101":{"body":225,"breadcrumbs":0,"title":0},"102":{"body":198,"breadcrumbs":1,"title":1},"103":{"body":82,"breadcrumbs":2,"title":1},"104":{"body":75,"breadcrumbs":1,"title":0},"105":{"body":114,"breadcrumbs":2,"title":1},"106":{"body":98,"breadcrumbs":1,"title":0},"107":{"body":67,"breadcrumbs":2,"title":1},"108":{"body":116,"breadcrumbs":0,"title":0},"109":{"body":5,"breadcrumbs":0,"title":0},"11":{"body":4,"breadcrumbs":0,"title":0},"110":{"body":28,"breadcrumbs":2,"title":1},"111":{"body":87,"breadcrumbs":3,"title":1},"112":{"body":13,"breadcrumbs":1,"title":0},"113":{"body":70,"breadcrumbs":1,"title":0},"114":{"body":72,"breadcrumbs":1,"title":0},"115":{"body":156,"breadcrumbs":1,"title":0},"116":{"body":161,"breadcrumbs":2,"title":1},"117":{"body":20,"breadcrumbs":2,"title":1},"118":{"body":32,"breadcrumbs":2,"title":1},"119":{"body":93,"breadcrumbs":1,"title":0},"12":{"body":14,"breadcrumbs":0,"title":0},"120":{"body":151,"breadcrumbs":3,"title":1},"121":{"body":89,"breadcrumbs":3,"title":1},"122":{"body":33,"breadcrumbs":2,"title":0},"123":{"body":45,"breadcrumbs":4,"title":2},"124":{"body":60,"breadcrumbs":2,"title":0},"125":{"body":133,"breadcrumbs":3,"title":1},"126":{"body":11,"breadcrumbs":3,"title":1},"127":{"body":85,"breadcrumbs":1,"title":0},"128":{"body":19,"breadcrumbs":1,"title":0},"129":{"body":5,"breadcrumbs":1,"title":0},"13":{"body":16,"breadcrumbs":0,"title":0},"130":{"body":18,"breadcrumbs":0,"title":0},"131":{"body":8,"breadcrumbs":2,"title":1},"132":{"body":47,"breadcrumbs":2,"title":1},"133":{"body":21,"breadcrumbs":2,"title":1},"134":{"body":158,"breadcrumbs":2,"title":1},"135":{"body":42,"breadcrumbs":2,"title":1},"136":{"body":36,"breadcrumbs":1,"title":0},"137":{"body":25,"breadcrumbs":2,"title":1},"138":{"body":12,"breadcrumbs":4,"title":2},"139":{"body":22,"breadcrumbs":2,"title":0},"14":{"body":1,"breadcrumbs":0,"title":0},"140":{"body":87,"breadcrumbs":2,"title":0},"141":{"body":167,"breadcrumbs":2,"title":0},"142":{"body":210,"breadcrumbs":2,"title":0},"143":{"body":49,"breadcrumbs":3,"title":1},"144":{"body":20,"breadcrumbs":2,"title":0},"145":{"body":23,"breadcrumbs":2,"title":0},"146":{"body":22,"breadcrumbs":4,"title":2},"147":{"body":32,"breadcrumbs":3,"title":1},"148":{"body":53,"breadcrumbs":3,"title":1},"149":{"body":34,"breadcrumbs":3,"title":1},"15":{"body":33,"breadcrumbs":3,"title":3},"150":{"body":106,"breadcrumbs":3,"title":1},"151":{"body":16,"breadcrumbs":2,"title":0},"152":{"body":20,"breadcrumbs":2,"title":0},"153":{"body":17,"breadcrumbs":0,"title":0},"154":{"body":18,"breadcrumbs":2,"title":1},"155":{"body":59,"breadcrumbs":2,"title":1},"156":{"body":153,"breadcrumbs":3,"title":2},"157":{"body":138,"breadcrumbs":2,"title":1},"158":{"body":99,"breadcrumbs":1,"title":0},"159":{"body":84,"breadcrumbs":4,"title":3},"16":{"body":10,"breadcrumbs":2,"title":2},"160":{"body":87,"breadcrumbs":1,"title":0},"161":{"body":110,"breadcrumbs":1,"title":0},"162":{"body":246,"breadcrumbs":1,"title":0},"163":{"body":18,"breadcrumbs":2,"title":1},"164":{"body":5,"breadcrumbs":2,"title":1},"165":{"body":33,"breadcrumbs":1,"title":0},"166":{"body":17,"breadcrumbs":1,"title":0},"167":{"body":160,"breadcrumbs":1,"title":0},"168":{"body":8,"breadcrumbs":1,"title":0},"169":{"body":18,"breadcrumbs":2,"title":1},"17":{"body":28,"breadcrumbs":1,"title":1},"170":{"body":156,"breadcrumbs":1,"title":0},"171":{"body":5,"breadcrumbs":1,"title":0},"172":{"body":195,"breadcrumbs":1,"title":0},"173":{"body":151,"breadcrumbs":1,"title":0},"174":{"body":33,"breadcrumbs":1,"title":0},"175":{"body":200,"breadcrumbs":1,"title":0},"176":{"body":35,"breadcrumbs":1,"title":0},"177":{"body":11,"breadcrumbs":3,"title":1},"178":{"body":39,"breadcrumbs":3,"title":1},"179":{"body":165,"breadcrumbs":3,"title":1},"18":{"body":9,"breadcrumbs":0,"title":0},"180":{"body":240,"breadcrumbs":2,"title":0},"181":{"body":203,"breadcrumbs":3,"title":1},"182":{"body":194,"breadcrumbs":3,"title":1},"183":{"body":100,"breadcrumbs":4,"title":2},"184":{"body":9,"breadcrumbs":1,"title":0},"185":{"body":144,"breadcrumbs":1,"title":0},"186":{"body":137,"breadcrumbs":1,"title":0},"187":{"body":15,"breadcrumbs":1,"title":0},"188":{"body":202,"breadcrumbs":1,"title":0},"189":{"body":100,"breadcrumbs":1,"title":0},"19":{"body":4,"breadcrumbs":0,"title":0},"190":{"body":35,"breadcrumbs":1,"title":0},"191":{"body":129,"breadcrumbs":3,"title":2},"192":{"body":83,"breadcrumbs":1,"title":0},"193":{"body":12,"breadcrumbs":1,"title":0},"194":{"body":51,"breadcrumbs":3,"title":2},"195":{"body":10,"breadcrumbs":1,"title":0},"196":{"body":32,"breadcrumbs":0,"title":0},"197":{"body":10,"breadcrumbs":0,"title":0},"198":{"body":374,"breadcrumbs":0,"title":0},"199":{"body":421,"breadcrumbs":1,"title":1},"2":{"body":14,"breadcrumbs":0,"title":0},"20":{"body":20,"breadcrumbs":4,"title":2},"200":{"body":234,"breadcrumbs":2,"title":2},"201":{"body":205,"breadcrumbs":0,"title":0},"202":{"body":448,"breadcrumbs":2,"title":2},"203":{"body":62,"breadcrumbs":2,"title":2},"204":{"body":25,"breadcrumbs":0,"title":0},"205":{"body":9,"breadcrumbs":0,"title":0},"206":{"body":216,"breadcrumbs":0,"title":0},"207":{"body":207,"breadcrumbs":0,"title":0},"208":{"body":180,"breadcrumbs":0,"title":0},"209":{"body":10,"breadcrumbs":0,"title":0},"21":{"body":30,"breadcrumbs":2,"title":0},"210":{"body":88,"breadcrumbs":0,"title":0},"211":{"body":387,"breadcrumbs":0,"title":0},"212":{"body":5,"breadcrumbs":0,"title":0},"213":{"body":27,"breadcrumbs":2,"title":1},"214":{"body":32,"breadcrumbs":1,"title":0},"215":{"body":31,"breadcrumbs":1,"title":0},"216":{"body":64,"breadcrumbs":3,"title":2},"217":{"body":53,"breadcrumbs":1,"title":0},"218":{"body":121,"breadcrumbs":1,"title":0},"219":{"body":21,"breadcrumbs":1,"title":0},"22":{"body":38,"breadcrumbs":3,"title":1},"220":{"body":18,"breadcrumbs":1,"title":0},"221":{"body":62,"breadcrumbs":1,"title":0},"222":{"body":88,"breadcrumbs":1,"title":0},"223":{"body":76,"breadcrumbs":2,"title":1},"224":{"body":354,"breadcrumbs":1,"title":0},"225":{"body":347,"breadcrumbs":2,"title":1},"226":{"body":126,"breadcrumbs":2,"title":1},"227":{"body":17,"breadcrumbs":1,"title":0},"228":{"body":324,"breadcrumbs":1,"title":0},"229":{"body":530,"breadcrumbs":1,"title":0},"23":{"body":29,"breadcrumbs":3,"title":1},"230":{"body":7,"breadcrumbs":1,"title":0},"231":{"body":130,"breadcrumbs":2,"title":1},"232":{"body":759,"breadcrumbs":2,"title":1},"233":{"body":15,"breadcrumbs":1,"title":0},"234":{"body":13,"breadcrumbs":1,"title":0},"235":{"body":52,"breadcrumbs":1,"title":0},"236":{"body":4,"breadcrumbs":1,"title":0},"237":{"body":15,"breadcrumbs":2,"title":1},"238":{"body":7,"breadcrumbs":1,"title":0},"239":{"body":145,"breadcrumbs":1,"title":0},"24":{"body":63,"breadcrumbs":2,"title":0},"240":{"body":177,"breadcrumbs":1,"title":0},"241":{"body":203,"breadcrumbs":1,"title":0},"242":{"body":328,"breadcrumbs":3,"title":2},"243":{"body":48,"breadcrumbs":1,"title":0},"244":{"body":73,"breadcrumbs":4,"title":3},"245":{"body":41,"breadcrumbs":1,"title":0},"246":{"body":113,"breadcrumbs":1,"title":0},"247":{"body":85,"breadcrumbs":1,"title":0},"248":{"body":10,"breadcrumbs":3,"title":1},"249":{"body":603,"breadcrumbs":3,"title":1},"25":{"body":28,"breadcrumbs":4,"title":2},"250":{"body":267,"breadcrumbs":2,"title":0},"251":{"body":5,"breadcrumbs":2,"title":0},"252":{"body":98,"breadcrumbs":2,"title":1},"253":{"body":5,"breadcrumbs":1,"title":0},"254":{"body":12,"breadcrumbs":4,"title":2},"255":{"body":84,"breadcrumbs":2,"title":0},"256":{"body":11,"breadcrumbs":6,"title":2},"257":{"body":166,"breadcrumbs":4,"title":0},"258":{"body":270,"breadcrumbs":7,"title":3},"259":{"body":25,"breadcrumbs":5,"title":1},"26":{"body":103,"breadcrumbs":3,"title":1},"260":{"body":130,"breadcrumbs":5,"title":1},"261":{"body":43,"breadcrumbs":5,"title":1},"262":{"body":5,"breadcrumbs":5,"title":1},"263":{"body":31,"breadcrumbs":7,"title":3},"264":{"body":11,"breadcrumbs":4,"title":1},"265":{"body":58,"breadcrumbs":3,"title":0},"266":{"body":458,"breadcrumbs":3,"title":0},"267":{"body":73,"breadcrumbs":6,"title":2},"268":{"body":22,"breadcrumbs":4,"title":1},"269":{"body":6,"breadcrumbs":3,"title":0},"27":{"body":119,"breadcrumbs":3,"title":1},"270":{"body":40,"breadcrumbs":0,"title":0},"271":{"body":15,"breadcrumbs":2,"title":1},"272":{"body":32,"breadcrumbs":2,"title":1},"273":{"body":217,"breadcrumbs":2,"title":1},"274":{"body":44,"breadcrumbs":1,"title":0},"275":{"body":81,"breadcrumbs":2,"title":1},"276":{"body":20,"breadcrumbs":4,"title":2},"277":{"body":86,"breadcrumbs":2,"title":0},"278":{"body":33,"breadcrumbs":3,"title":1},"279":{"body":101,"breadcrumbs":2,"title":0},"28":{"body":10,"breadcrumbs":3,"title":1},"280":{"body":84,"breadcrumbs":4,"title":2},"281":{"body":162,"breadcrumbs":3,"title":1},"282":{"body":29,"breadcrumbs":3,"title":1},"283":{"body":322,"breadcrumbs":4,"title":2},"284":{"body":11,"breadcrumbs":2,"title":1},"285":{"body":177,"breadcrumbs":2,"title":1},"286":{"body":111,"breadcrumbs":2,"title":1},"287":{"body":14,"breadcrumbs":2,"title":1},"288":{"body":25,"breadcrumbs":2,"title":1},"289":{"body":539,"breadcrumbs":1,"title":0},"29":{"body":14,"breadcrumbs":3,"title":1},"290":{"body":231,"breadcrumbs":2,"title":1},"291":{"body":128,"breadcrumbs":3,"title":2},"292":{"body":14,"breadcrumbs":0,"title":0},"293":{"body":252,"breadcrumbs":0,"title":0},"294":{"body":412,"breadcrumbs":2,"title":2},"295":{"body":9,"breadcrumbs":0,"title":0},"296":{"body":28,"breadcrumbs":0,"title":0},"297":{"body":16,"breadcrumbs":0,"title":0},"298":{"body":276,"breadcrumbs":1,"title":1},"299":{"body":274,"breadcrumbs":1,"title":1},"3":{"body":1,"breadcrumbs":1,"title":1},"30":{"body":10,"breadcrumbs":2,"title":0},"300":{"body":117,"breadcrumbs":0,"title":0},"301":{"body":105,"breadcrumbs":0,"title":0},"302":{"body":44,"breadcrumbs":0,"title":0},"303":{"body":60,"breadcrumbs":0,"title":0},"304":{"body":11,"breadcrumbs":0,"title":0},"305":{"body":6,"breadcrumbs":0,"title":0},"306":{"body":396,"breadcrumbs":2,"title":2},"307":{"body":23,"breadcrumbs":2,"title":2},"308":{"body":13,"breadcrumbs":6,"title":3},"309":{"body":25,"breadcrumbs":4,"title":1},"31":{"body":14,"breadcrumbs":0,"title":0},"310":{"body":22,"breadcrumbs":4,"title":1},"311":{"body":12,"breadcrumbs":5,"title":2},"312":{"body":12,"breadcrumbs":3,"title":0},"313":{"body":31,"breadcrumbs":4,"title":2},"314":{"body":21,"breadcrumbs":2,"title":0},"315":{"body":50,"breadcrumbs":6,"title":2},"316":{"body":532,"breadcrumbs":4,"title":0},"317":{"body":9,"breadcrumbs":4,"title":1},"318":{"body":338,"breadcrumbs":3,"title":0},"319":{"body":321,"breadcrumbs":3,"title":0},"32":{"body":57,"breadcrumbs":0,"title":0},"320":{"body":839,"breadcrumbs":4,"title":1},"321":{"body":75,"breadcrumbs":4,"title":1},"322":{"body":375,"breadcrumbs":4,"title":1},"323":{"body":177,"breadcrumbs":3,"title":0},"324":{"body":0,"breadcrumbs":4,"title":1},"325":{"body":0,"breadcrumbs":6,"title":2},"326":{"body":0,"breadcrumbs":4,"title":1},"327":{"body":22,"breadcrumbs":2,"title":1},"328":{"body":7,"breadcrumbs":1,"title":0},"329":{"body":40,"breadcrumbs":1,"title":0},"33":{"body":100,"breadcrumbs":0,"title":0},"330":{"body":105,"breadcrumbs":1,"title":0},"331":{"body":28,"breadcrumbs":1,"title":0},"332":{"body":35,"breadcrumbs":3,"title":1},"333":{"body":155,"breadcrumbs":3,"title":1},"334":{"body":273,"breadcrumbs":3,"title":1},"335":{"body":14,"breadcrumbs":3,"title":1},"336":{"body":56,"breadcrumbs":1,"title":0},"337":{"body":68,"breadcrumbs":2,"title":1},"338":{"body":61,"breadcrumbs":1,"title":0},"339":{"body":57,"breadcrumbs":1,"title":0},"34":{"body":56,"breadcrumbs":0,"title":0},"340":{"body":138,"breadcrumbs":1,"title":0},"341":{"body":453,"breadcrumbs":3,"title":2},"342":{"body":272,"breadcrumbs":1,"title":0},"343":{"body":5,"breadcrumbs":1,"title":0},"344":{"body":13,"breadcrumbs":0,"title":0},"345":{"body":7,"breadcrumbs":0,"title":0},"346":{"body":31,"breadcrumbs":1,"title":1},"347":{"body":71,"breadcrumbs":0,"title":0},"348":{"body":29,"breadcrumbs":0,"title":0},"349":{"body":50,"breadcrumbs":0,"title":0},"35":{"body":43,"breadcrumbs":0,"title":0},"350":{"body":104,"breadcrumbs":0,"title":0},"351":{"body":50,"breadcrumbs":0,"title":0},"352":{"body":171,"breadcrumbs":2,"title":1},"353":{"body":6,"breadcrumbs":0,"title":0},"354":{"body":17,"breadcrumbs":0,"title":0},"355":{"body":79,"breadcrumbs":0,"title":0},"356":{"body":19,"breadcrumbs":0,"title":0},"357":{"body":47,"breadcrumbs":0,"title":0},"358":{"body":323,"breadcrumbs":0,"title":0},"359":{"body":288,"breadcrumbs":0,"title":0},"36":{"body":100,"breadcrumbs":1,"title":1},"360":{"body":156,"breadcrumbs":0,"title":0},"361":{"body":55,"breadcrumbs":0,"title":0},"362":{"body":4,"breadcrumbs":0,"title":0},"363":{"body":19,"breadcrumbs":0,"title":0},"364":{"body":21,"breadcrumbs":2,"title":1},"365":{"body":18,"breadcrumbs":1,"title":0},"366":{"body":76,"breadcrumbs":1,"title":0},"367":{"body":433,"breadcrumbs":1,"title":0},"368":{"body":55,"breadcrumbs":1,"title":0},"369":{"body":47,"breadcrumbs":2,"title":1},"37":{"body":37,"breadcrumbs":1,"title":1},"370":{"body":6,"breadcrumbs":1,"title":0},"371":{"body":4,"breadcrumbs":1,"title":0},"372":{"body":8,"breadcrumbs":2,"title":1},"373":{"body":112,"breadcrumbs":2,"title":1},"374":{"body":161,"breadcrumbs":1,"title":0},"375":{"body":473,"breadcrumbs":1,"title":0},"376":{"body":305,"breadcrumbs":4,"title":3},"377":{"body":75,"breadcrumbs":3,"title":2},"378":{"body":12,"breadcrumbs":0,"title":0},"379":{"body":23,"breadcrumbs":1,"title":1},"38":{"body":24,"breadcrumbs":0,"title":0},"380":{"body":239,"breadcrumbs":0,"title":0},"381":{"body":157,"breadcrumbs":2,"title":2},"382":{"body":82,"breadcrumbs":2,"title":2},"383":{"body":7,"breadcrumbs":0,"title":0},"384":{"body":114,"breadcrumbs":0,"title":0},"385":{"body":100,"breadcrumbs":0,"title":0},"386":{"body":15,"breadcrumbs":0,"title":0},"387":{"body":13,"breadcrumbs":0,"title":0},"388":{"body":81,"breadcrumbs":1,"title":1},"389":{"body":30,"breadcrumbs":0,"title":0},"39":{"body":6,"breadcrumbs":0,"title":0},"390":{"body":378,"breadcrumbs":1,"title":1},"391":{"body":25,"breadcrumbs":0,"title":0},"392":{"body":20,"breadcrumbs":0,"title":0},"393":{"body":1,"breadcrumbs":0,"title":0},"394":{"body":37,"breadcrumbs":4,"title":2},"395":{"body":33,"breadcrumbs":6,"title":2},"396":{"body":87,"breadcrumbs":5,"title":1},"397":{"body":191,"breadcrumbs":4,"title":0},"398":{"body":82,"breadcrumbs":4,"title":0},"399":{"body":102,"breadcrumbs":5,"title":1},"4":{"body":10,"breadcrumbs":0,"title":0},"40":{"body":207,"breadcrumbs":1,"title":1},"400":{"body":179,"breadcrumbs":4,"title":0},"401":{"body":65,"breadcrumbs":4,"title":0},"402":{"body":7,"breadcrumbs":6,"title":2},"403":{"body":86,"breadcrumbs":5,"title":1},"404":{"body":1638,"breadcrumbs":4,"title":0},"405":{"body":21,"breadcrumbs":2,"title":0},"406":{"body":637,"breadcrumbs":5,"title":3},"407":{"body":649,"breadcrumbs":2,"title":0},"408":{"body":4,"breadcrumbs":2,"title":0},"409":{"body":5,"breadcrumbs":0,"title":0},"41":{"body":115,"breadcrumbs":0,"title":0},"410":{"body":6,"breadcrumbs":0,"title":0},"411":{"body":55,"breadcrumbs":0,"title":0},"412":{"body":13,"breadcrumbs":0,"title":0},"413":{"body":60,"breadcrumbs":0,"title":0},"414":{"body":7,"breadcrumbs":2,"title":1},"415":{"body":155,"breadcrumbs":1,"title":0},"416":{"body":144,"breadcrumbs":1,"title":0},"417":{"body":33,"breadcrumbs":4,"title":2},"418":{"body":7,"breadcrumbs":3,"title":1},"419":{"body":21,"breadcrumbs":4,"title":2},"42":{"body":333,"breadcrumbs":0,"title":0},"420":{"body":30,"breadcrumbs":4,"title":2},"421":{"body":37,"breadcrumbs":4,"title":2},"422":{"body":12,"breadcrumbs":3,"title":1},"423":{"body":19,"breadcrumbs":3,"title":1},"424":{"body":9,"breadcrumbs":2,"title":1},"425":{"body":20,"breadcrumbs":2,"title":1},"426":{"body":73,"breadcrumbs":2,"title":1},"427":{"body":70,"breadcrumbs":3,"title":2},"428":{"body":23,"breadcrumbs":4,"title":3},"429":{"body":50,"breadcrumbs":2,"title":1},"43":{"body":117,"breadcrumbs":0,"title":0},"430":{"body":21,"breadcrumbs":2,"title":1},"431":{"body":8,"breadcrumbs":7,"title":3},"432":{"body":6,"breadcrumbs":4,"title":0},"433":{"body":91,"breadcrumbs":8,"title":4},"434":{"body":8,"breadcrumbs":4,"title":0},"435":{"body":51,"breadcrumbs":7,"title":3},"436":{"body":19,"breadcrumbs":5,"title":1},"44":{"body":54,"breadcrumbs":0,"title":0},"45":{"body":186,"breadcrumbs":0,"title":0},"46":{"body":6,"breadcrumbs":0,"title":0},"47":{"body":11,"breadcrumbs":0,"title":0},"48":{"body":3,"breadcrumbs":0,"title":0},"49":{"body":144,"breadcrumbs":0,"title":0},"5":{"body":2,"breadcrumbs":0,"title":0},"50":{"body":15,"breadcrumbs":0,"title":0},"51":{"body":116,"breadcrumbs":0,"title":0},"52":{"body":70,"breadcrumbs":0,"title":0},"53":{"body":232,"breadcrumbs":0,"title":0},"54":{"body":192,"breadcrumbs":0,"title":0},"55":{"body":57,"breadcrumbs":0,"title":0},"56":{"body":89,"breadcrumbs":0,"title":0},"57":{"body":125,"breadcrumbs":0,"title":0},"58":{"body":134,"breadcrumbs":0,"title":0},"59":{"body":48,"breadcrumbs":0,"title":0},"6":{"body":4,"breadcrumbs":0,"title":0},"60":{"body":6,"breadcrumbs":0,"title":0},"61":{"body":285,"breadcrumbs":0,"title":0},"62":{"body":269,"breadcrumbs":0,"title":0},"63":{"body":5,"breadcrumbs":0,"title":0},"64":{"body":12,"breadcrumbs":0,"title":0},"65":{"body":9,"breadcrumbs":0,"title":0},"66":{"body":14,"breadcrumbs":1,"title":1},"67":{"body":2,"breadcrumbs":0,"title":0},"68":{"body":22,"breadcrumbs":0,"title":0},"69":{"body":23,"breadcrumbs":1,"title":1},"7":{"body":3,"breadcrumbs":0,"title":0},"70":{"body":287,"breadcrumbs":0,"title":0},"71":{"body":42,"breadcrumbs":0,"title":0},"72":{"body":69,"breadcrumbs":0,"title":0},"73":{"body":148,"breadcrumbs":0,"title":0},"74":{"body":222,"breadcrumbs":0,"title":0},"75":{"body":152,"breadcrumbs":2,"title":2},"76":{"body":1,"breadcrumbs":0,"title":0},"77":{"body":147,"breadcrumbs":2,"title":1},"78":{"body":335,"breadcrumbs":2,"title":1},"79":{"body":21,"breadcrumbs":2,"title":1},"8":{"body":9,"breadcrumbs":0,"title":0},"80":{"body":5,"breadcrumbs":1,"title":0},"81":{"body":10,"breadcrumbs":0,"title":0},"82":{"body":139,"breadcrumbs":0,"title":0},"83":{"body":54,"breadcrumbs":0,"title":0},"84":{"body":115,"breadcrumbs":0,"title":0},"85":{"body":29,"breadcrumbs":0,"title":0},"86":{"body":19,"breadcrumbs":0,"title":0},"87":{"body":110,"breadcrumbs":0,"title":0},"88":{"body":81,"breadcrumbs":0,"title":0},"89":{"body":25,"breadcrumbs":0,"title":0},"9":{"body":0,"breadcrumbs":0,"title":0},"90":{"body":55,"breadcrumbs":0,"title":0},"91":{"body":240,"breadcrumbs":1,"title":1},"92":{"body":10,"breadcrumbs":0,"title":0},"93":{"body":129,"breadcrumbs":0,"title":0},"94":{"body":57,"breadcrumbs":0,"title":0},"95":{"body":136,"breadcrumbs":0,"title":0},"96":{"body":39,"breadcrumbs":0,"title":0},"97":{"body":68,"breadcrumbs":1,"title":1},"98":{"body":2,"breadcrumbs":0,"title":0},"99":{"body":9,"breadcrumbs":0,"title":0}},"docs":{"0":{"body":"title-page.md commit d94e03a18a2590ed3f1c67b859cb11528d2a2d5c 本书的英文原版作者为 Steve Klabnik 和 Carol Nichols,并由 Rust 社区补充完善。本简体中文译本由 Rust 中文社区翻译。 本书假设你使用 Rust 1.78.0(2024-05-02 发布)或更新的版本。请查看 第 1 章的 “安装” 部分 了解如何安装和升级 Rust。 本书的英文原版 HTML 格式可以在 https://doc.rust-lang.org/stable/book/ 在线阅读;使用 rustup 安装的 Rust 也包含一份英文离线版,运行 rustup docs --book 即可打开。 本书还有一些社区 翻译版本 。简体中文译本可以在 https://kaisery.github.io/trpl-zh-cn/ 在线阅读。 本书也有 由 No Starch Press 出版的纸质版和电子版 。 🚨 想要具有互动性的学习体验吗?试试 Rust Book 的另一个版本,其中包括测验、高亮、可视化等功能 : https://rust-book.cs.brown.edu","breadcrumbs":"Rust 程序设计语言 » Rust 程序设计语言","id":"0","title":"Rust 程序设计语言"},"1":{"body":"foreword.md commit 1fedfc4b96c2017f64ecfcf41a0a07e2e815f24f Rust 程序设计语言的本质实际在于 赋能 ( empowerment ):无论你现在编写的是何种代码,Rust 能让你在更为广泛的编程领域走得更远,写出自信。(这一点并不显而易见) 举例来说,那些“系统层面”的工作涉及内存管理、数据表示和并发等底层细节。从传统角度来看,这是一个神秘的编程领域,只为浸润多年的极少数人所触及,也只有他们能避开那些臭名昭著的陷阱。即使谨慎的实践者,亦唯恐代码出现漏洞、崩溃或损坏。 Rust 破除了这些障碍:它消除了旧的陷阱,并提供了伴你一路同行的友好、精良的工具。想要 “深入” 底层控制的程序员可以使用 Rust,无需时刻担心出现崩溃或安全漏洞,也无需因为工具链不靠谱而被迫去了解其中的细节。更妙的是,语言设计本身会自然而然地引导你编写出可靠的代码,并且运行速度和内存使用上都十分高效。 已经在从事编写底层代码的程序员可以使用 Rust 来提升信心。例如,在 Rust 中引入并行是相对低风险的操作,因为编译器会替你找到经典的错误。同时你可以自信地采取更加激进的优化,而不会意外引入崩溃或漏洞。 但 Rust 并不局限于底层系统编程。它表达力强、写起来舒适,让人能够轻松地编写出命令行应用、网络服务器等各种类型的代码——在本书中就有这两者的简单示例。使用 Rust 能让你把在一个领域中学习的技能延伸到另一个领域:你可以通过编写网页应用来学习 Rust,接着将同样的技能应用到你的 Raspberry Pi(树莓派)上。 本书全面介绍了 Rust 为用户赋予的能力。其内容平易近人,致力于帮助你提升 Rust 的知识,并且提升你作为程序员整体的理解与自信。欢迎你加入 Rust 社区,让我们准备深入学习 Rust 吧! —— Nicholas Matsakis 和 Aaron Turon","breadcrumbs":"前言 » 前言","id":"1","title":"前言"},"10":{"body":"本书大体上假设您按从头到尾的顺序阅读。后面的章节建立在前面章节概念的基础上。前面的章节可能不会深入介绍部分主题,而是留待后续章节重新讨论。 本书分为两类章节:概念章节和项目章节。在概念章节中,我们学习 Rust 的某个方面。在项目章节中,我们应用目前所学的知识一同构建小型程序。第二、十二和二十章是项目章节;其余都是概念章节。 第一章介绍如何安装 Rust,如何编写一个 “Hello, world!” 程序,以及如何使用 Rust 的包管理器和构建工具 Cargo。第二章是一个编写 Rust 语言的实战介绍,我们会构建一个猜数字游戏。我们会站在较高的层次介绍一些概念,而后续章节将提供更多细节。如果你希望立刻就动手实践一下,第二章是开始的好地方。第三章介绍 Rust 中类似其他编程语言的特性,第四章会学习 Rust 的所有权系统。如果你是一个特别细致的学习者,喜欢在进入下一环节之前学习每一个细节,你可能会想要跳过第二章,直接阅读第三章,等到你想要通过项目应用所学到的细节时再回到第二章。 第五章讨论结构体(struct)和方法,第六章介绍枚举(enum)、match 表达式和 if let 控制流结构。在 Rust 中,创建自定义类型需要用到结构体和枚举。 第七章介绍 Rust 的模块(module)系统,其中的私有性规则用来组织代码和公开的 API(应用程序接口)。第八章讨论标准库提供的常见集合数据结构,例如 Vector(向量)、字符串和 Hash Map(散列表)。第九章探索 Rust 的错误处理的理念与技术。 第十章深入介绍泛型(generic)、Trait 和生命周期(lifetime),这些功能让你能够定义适用于多种类型的代码。第十一章全面讲述了测试,因为就算 Rust 有安全保证,也需要测试确保程序逻辑正确。第十二章中将会构建我们自己的 grep 命令行工具的功能子集实现,用于在文件中搜索文本。为此会用到之前章节讨论的很多概念。 第十三章探索闭包(closure)和迭代器(iterator),这两个 Rust 特性来自函数式编程语言。第十四章会深入探讨 Cargo 并介绍分享代码库的最佳实践。第十五章讨论标准库提供的智能指针以及相关的 Trait。 第十六章将引导我们了解不同的并发编程模型,并探讨 Rust 如何帮助你无畏地进行多线程编程。第十七章将在此基础上进一步探索 Rust 的 async 和 await 语法,以及它们所支持的轻量级并发模型。 第十八章着眼于 Rust 风格与你可能比较熟悉的 OOP(面向对象编程)原则之间的比较。 第十九章介绍模式和模式匹配,它是在 Rust 程序中表达思想的有效方式。第二十章是一个高级主题大杂烩,包括不安全 Rust(unsafe Rust)、宏(macro)和更多关于生命周期、Trait、类型、函数和闭包的内容。 第二十一章我们将会完成一个项目,实现一个底层的、多线程的 Web 服务器! 最后的附录包含了一些关于该语言的实用信息,其格式更像是参考资料。附录 A 涵盖了 Rust 的关键字,附录 B 涵盖了 Rust 的运算符和符号,附录 C 涵盖了标准库提供的可派生 Trait,附录 D 涵盖了一些有用的开发工具,而附录 E 解释了 Rust 版本。在附录 F 中,你可以找到本书的翻译版本,而在附录 G 中,我们将讨论 Rust 是如何制作的以及什么是 nightly Rust。 阅读本书没有错误的方式:如果你想跳过前面的内容,尽管跳过!如果你遇到任何困惑,可能需要回到前面的章节。请采取对你最有效的方式。 学习 Rust 的一个重要部分是学会如何阅读编译器显示的错误信息:它们会指引你编写出能运行的代码。为此,我们将提供许多不能编译的示例,以及在每种情况下编译器将显示的错误信息。请知悉,如果你输入并运行一个随机示例,它可能无法编译!确保你阅读了示例周围的文本,以判断你尝试运行的示例是否出错。Ferris 也将帮助你区分那些不是意在工作的代码: Ferris 含义 这段代码无法通过编译! 这段代码会 Panic! 这段代码的运行结果不符合预期。 在大部分情况,我们会指导你将无法通过编译的代码修改为正确版本。","breadcrumbs":"简介 » 如何阅读本书","id":"10","title":"如何阅读本书"},"100":{"body":"ch06-01-defining-an-enum.md commit bb7e429ad6b59d9a0c37db7434976364cbb9c6da 结构体给予你将字段和数据聚合在一起的方法,像 Rectangle 结构体有 width 和 height 两个字段。而枚举给予你一个途径去声明某个值是一个集合中的一员。比如,我们想让 Rectangle 是一些形状的集合,包含 Circle 和 Triangle 。为了做到这个,Rust 提供了枚举类型。 让我们看看一个需要诉诸于代码的场景,来考虑为何此时使用枚举更为合适且实用。假设我们要处理 IP 地址。目前被广泛使用的两个主要 IP 标准:IPv4(version four)和 IPv6(version six)。这是我们的程序可能会遇到的所有可能的 IP 地址类型:所以可以 枚举 出所有可能的值,这也正是此枚举名字的由来。 任何一个 IP 地址要么是 IPv4 的要么是 IPv6 的,而且不能两者都是。IP 地址的这个特性使得枚举数据结构非常适合这个场景,因为枚举值只可能是其中一个成员。IPv4 和 IPv6 从根本上讲仍是 IP 地址,所以当代码在处理适用于任何类型的 IP 地址的场景时应该把它们当作相同的类型。 可以通过在代码中定义一个 IpAddrKind 枚举来表现这个概念并列出可能的 IP 地址类型,V4 和 V6。这被称为枚举的 成员 ( variants ): enum IpAddrKind { V4, V6,\n}\n# # fn main() {\n# let four = IpAddrKind::V4;\n# let six = IpAddrKind::V6;\n# # route(IpAddrKind::V4);\n# route(IpAddrKind::V6);\n# }\n# # fn route(ip_kind: IpAddrKind) {} 现在 IpAddrKind 就是一个可以在代码中使用的自定义数据类型了。","breadcrumbs":"枚举和模式匹配 » 枚举的定义 » 枚举的定义","id":"100","title":"枚举的定义"},"101":{"body":"可以像这样创建 IpAddrKind 两个不同成员的实例: # enum IpAddrKind {\n# V4,\n# V6,\n# }\n# # fn main() { let four = IpAddrKind::V4; let six = IpAddrKind::V6;\n# # route(IpAddrKind::V4);\n# route(IpAddrKind::V6);\n# }\n# # fn route(ip_kind: IpAddrKind) {} 注意枚举的成员位于其标识符的命名空间中,并使用两个冒号分开。这么设计的益处是现在 IpAddrKind::V4 和 IpAddrKind::V6 都是 IpAddrKind 类型的。例如,接着可以定义一个函数来接收任何 IpAddrKind类型的参数: # enum IpAddrKind {\n# V4,\n# V6,\n# }\n# # fn main() {\n# let four = IpAddrKind::V4;\n# let six = IpAddrKind::V6;\n# # route(IpAddrKind::V4);\n# route(IpAddrKind::V6);\n# }\n# fn route(ip_kind: IpAddrKind) {} 现在可以使用任一成员来调用这个函数: # enum IpAddrKind {\n# V4,\n# V6,\n# }\n# # fn main() {\n# let four = IpAddrKind::V4;\n# let six = IpAddrKind::V6;\n# route(IpAddrKind::V4); route(IpAddrKind::V6);\n# }\n# # fn route(ip_kind: IpAddrKind) {} 使用枚举甚至还有更多优势。进一步考虑一下我们的 IP 地址类型,目前没有一个存储实际 IP 地址 数据 的方法;只知道它是什么 类型 的。考虑到已经在第五章学习过结构体了,你可能会像示例 6-1 那样处理这个问题: # fn main() { enum IpAddrKind { V4, V6, } struct IpAddr { kind: IpAddrKind, address: String, } let home = IpAddr { kind: IpAddrKind::V4, address: String::from(\"127.0.0.1\"), }; let loopback = IpAddr { kind: IpAddrKind::V6, address: String::from(\"::1\"), };\n# } 示例 6-1:将 IP 地址的数据和 IpAddrKind 成员存储在一个 struct 中 这里我们定义了一个有两个字段的结构体 IpAddr:IpAddrKind(之前定义的枚举)类型的 kind 字段和 String 类型 address 字段。我们有这个结构体的两个实例。第一个,home,它的 kind 的值是 IpAddrKind::V4 与之相关联的地址数据是 127.0.0.1。第二个实例,loopback,kind 的值是 IpAddrKind 的另一个成员,V6,关联的地址是 ::1。我们使用了一个结构体来将 kind 和 address 打包在一起,现在枚举成员就与值相关联了。 我们可以使用一种更简洁的方式来表达相同的概念,仅仅使用枚举并将数据直接放进每一个枚举成员而不是将枚举作为结构体的一部分。IpAddr 枚举的新定义表明了 V4 和 V6 成员都关联了 String 值: # fn main() { enum IpAddr { V4(String), V6(String), } let home = IpAddr::V4(String::from(\"127.0.0.1\")); let loopback = IpAddr::V6(String::from(\"::1\"));\n# } 我们直接将数据附加到枚举的每个成员上,这样就不需要一个额外的结构体了。这里也很容易看出枚举工作的另一个细节:每一个我们定义的枚举成员的名字也变成了一个构建枚举的实例的函数。也就是说,IpAddr::V4() 是一个获取 String 参数并返回 IpAddr 类型实例的函数调用。作为定义枚举的结果,这些构造函数会自动被定义。 用枚举替代结构体还有另一个优势:每个成员可以处理不同类型和数量的数据。IPv4 版本的 IP 地址总是含有四个值在 0 和 255 之间的数字部分。如果我们想要将 V4 地址存储为四个 u8 值而 V6 地址仍然表现为一个 String,这就不能使用结构体了。枚举则可以轻易的处理这个情况: # fn main() { enum IpAddr { V4(u8, u8, u8, u8), V6(String), } let home = IpAddr::V4(127, 0, 0, 1); let loopback = IpAddr::V6(String::from(\"::1\"));\n# } 这些代码展示了使用枚举来存储两种不同 IP 地址的几种可能的选择。然而,事实证明存储和编码 IP 地址实在是太常见了 以致标准库提供了一个开箱即用的定义! 让我们看看标准库是如何定义 IpAddr 的:它正有着跟我们定义和使用的一样的枚举和成员,不过它将成员中的地址数据嵌入到了两个不同形式的结构体中,它们对不同的成员的定义是不同的: struct Ipv4Addr { // --snip--\n} struct Ipv6Addr { // --snip--\n} enum IpAddr { V4(Ipv4Addr), V6(Ipv6Addr),\n} 这些代码展示了可以将任意类型的数据放入枚举成员中:例如字符串、数字类型或者结构体。甚至可以包含另一个枚举!另外,标准库中的类型通常并不比你设想出来的要复杂多少。 注意虽然标准库中包含一个 IpAddr 的定义,仍然可以创建和使用我们自己的定义而不会有冲突,因为我们并没有将标准库中的定义引入作用域。第七章会讲到如何导入类型。 来看看示例 6-2 中的另一个枚举的例子:它的成员中内嵌了多种多样的类型: enum Message { Quit, Move { x: i32, y: i32 }, Write(String), ChangeColor(i32, i32, i32),\n}\n# # fn main() {} 示例 6-2:一个 Message 枚举,其每个成员都存储了不同数量和类型的值 这个枚举有四个含有不同类型的成员: Quit 没有关联任何数据。 Move 类似结构体包含命名字段。 Write 包含单独一个 String。 ChangeColor 包含三个 i32。 定义一个如示例 6-2 中所示那样的有关联值的枚举的方式和定义多个不同类型的结构体的方式很相像,除了枚举不使用 struct 关键字以及其所有成员都被组合在一起位于 Message 类型下。如下这些结构体可以包含与之前枚举成员中相同的数据: struct QuitMessage; // 类单元结构体\nstruct MoveMessage { x: i32, y: i32,\n}\nstruct WriteMessage(String); // 元组结构体\nstruct ChangeColorMessage(i32, i32, i32); // 元组结构体\n# # fn main() {} 不过,如果我们使用不同的结构体,由于它们都有不同的类型,我们将不能像使用示例 6-2 中定义的 Message 枚举那样,轻易的定义一个能够处理这些不同类型的结构体的函数,因为枚举是单独一个类型。 结构体和枚举还有另一个相似点:就像可以使用 impl 来为结构体定义方法那样,也可以在枚举上定义方法。这是一个定义于我们 Message 枚举上的叫做 call 的方法: # fn main() {\n# enum Message {\n# Quit,\n# Move { x: i32, y: i32 },\n# Write(String),\n# ChangeColor(i32, i32, i32),\n# }\n# impl Message { fn call(&self) { // 在这里定义方法体 } } let m = Message::Write(String::from(\"hello\")); m.call();\n# } 方法体使用了 self 来获取调用方法的值。这个例子中,创建了一个值为 Message::Write(String::from(\"hello\")) 的变量 m,而且这就是当 m.call() 运行时 call 方法中的 self 的值。 让我们看看标准库中的另一个非常常见且实用的枚举:Option。","breadcrumbs":"枚举和模式匹配 » 枚举的定义 » 枚举值","id":"101","title":"枚举值"},"102":{"body":"这一部分会分析一个 Option 的案例,Option 是标准库定义的另一个枚举。Option 类型应用广泛因为它编码了一个非常普遍的场景,即一个值要么有值要么没值。 例如,如果请求一个非空列表的第一项,会得到一个值,如果请求一个空的列表,就什么也不会得到。从类型系统的角度来表达这个概念就意味着编译器需要检查是否处理了所有应该处理的情况,这样就可以避免在其他编程语言中非常常见的 bug。 编程语言的设计经常要考虑包含哪些功能,但考虑排除哪些功能也很重要。Rust 并没有很多其他语言中有的空值功能。 空值 ( Null )是一个值,它代表没有值。在有空值的语言中,变量总是这两种状态之一:空值和非空值。 Tony Hoare,null 的发明者,在他 2009 年的演讲 “Null References: The Billion Dollar Mistake” 中曾经说到: I call it my billion-dollar mistake. At that time, I was designing the first comprehensive type system for references in an object-oriented language. My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years. 我称之为我十亿美元的错误。当时,我在为一个面向对象语言设计第一个综合性的面向引用的类型系统。我的目标是通过编译器的自动检查来保证所有引用的使用都应该是绝对安全的。不过我未能抵抗住引入一个空引用的诱惑,仅仅是因为它是这么的容易实现。这引发了无数错误、漏洞和系统崩溃,在之后的四十多年中造成了数十亿美元的苦痛和伤害。 空值的问题在于当你尝试像一个非空值那样使用一个空值,会出现某种形式的错误。因为空和非空的属性无处不在,非常容易出现这类错误。 然而,空值尝试表达的概念仍然是有意义的:空值是一个因为某种原因目前无效或缺失的值。 问题不在于概念而在于具体的实现。为此,Rust 并没有空值,不过它确实拥有一个可以编码存在或不存在概念的枚举。这个枚举是 Option,而且它 定义于标准库中 ,如下: enum Option { None, Some(T),\n} Option 枚举是如此有用以至于它甚至被包含在了 prelude 之中,你不需要将其显式引入作用域。另外,它的成员也是如此,可以不需要 Option:: 前缀来直接使用 Some 和 None。即便如此 Option 也仍是常规的枚举,Some(T) 和 None 仍是 Option 的成员。 语法是一个我们还未讲到的 Rust 功能。它是一个泛型类型参数,第十章会更详细的讲解泛型。目前,所有你需要知道的就是 意味着 Option 枚举的 Some 成员可以包含任意类型的数据,同时每一个用于 T 位置的具体类型使得 Option 整体作为不同的类型。这里是一些包含数字类型和字符串类型 Option 值的例子: # fn main() { let some_number = Some(5); let some_char = Some('e'); let absent_number: Option = None;\n# } some_number 的类型是 Option。some_char 的类型是 Option,这(与 some_number)是一个不同的类型。因为我们在 Some 成员中指定了值,Rust 可以推断其类型。对于 absent_number,Rust 需要我们指定 Option 整体的类型,因为编译器只通过 None 值无法推断出 Some 成员保存的值的类型。这里我们告诉 Rust 希望 absent_number 是 Option 类型的。 当有一个 Some 值时,我们就知道存在一个值,而这个值保存在 Some 中。当有个 None 值时,在某种意义上,它跟空值具有相同的意义:并没有一个有效的值。那么,Option 为什么就比空值要好呢? 简而言之,因为 Option 和 T(这里 T 可以是任何类型)是不同的类型,编译器不允许像一个肯定有效的值那样使用 Option。例如,这段代码不能编译,因为它尝试将 Option 与 i8 相加: # fn main() { let x: i8 = 5; let y: Option = Some(5); let sum = x + y;\n# } 如果运行这些代码,将得到类似这样的错误信息: $ cargo run Compiling enums v0.1.0 (file:///projects/enums)\nerror[E0277]: cannot add `Option` to `i8` --> src/main.rs:5:17 |\n5 | let sum = x + y; | ^ no implementation for `i8 + Option` | = help: the trait `Add