The Servo Book - 0.0.1for the test harness (libtest).Building Servo If this is your first time building Servo, be sure to set up your environment before continuing with the steps below. To build servoshell for your machine: you start encountering build problems after updating Servo, try running ./mach bootstrap again, or set up your environment from the beginning. You are not alone! If you have problems building Servo that you start encountering build problems after updating Servo, try running ./mach bootstrap again, or set up your environment from the beginning. You are not alone! If you have problems setting up your environment0 码力 | 107 页 | 2.48 MB | 3 天前3
Rust 程序设计语言 简体中文版 1.85.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 9.2. 用 Result 处理可恢复的错误 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 当前程序并不需要了解如此多细节。现在,我们只需知道它像变量一样,默认是不可变的。因 此,需要写成 &mut guess 来使其可变,而不是 &guess。(第四章会更全面地讲解引用。) 使用 Result 类型来处理潜在的错误 我们还没有完全分析完这行代码。虽然我们已经讲到了第三行代码,但要注意:它仍是逻辑行 (虽然换行了但仍是语句)的一部分。后一部分是这个方法(method): read_line 会将用户输入附加到传递给它的字符串中,不过它也会返回一个类型为 Result 的值。Result 是一种枚举类型,通常也写作 enum,它可以是多种可能状态中的一个。 我们把每种可能的状态称为一种 枚举成员(variant)。 第六章将介绍枚举的更多细节。这里的 Result 类型将用来编码错误处理的信息。 Result 的成员是 Ok 和 Err,Ok 成员表示操作成功,内部包含成功时产生的值。Err0 码力 | 562 页 | 3.23 MB | 1 月前3
共 2 条
- 1













