Update ch09-03-to-panic-or-not-to-panic.md

示例 9-13 没有显示
pull/796/head
Sunman 3 months ago committed by GitHub
parent 5f7349f40d
commit 3e45c27c65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -59,7 +59,7 @@
相反我们可以创建一个新类型来将验证放入创建其实例的函数中,而不是到处重复这些检查。这样就可以安全地在函数签名中使用新类型并相信它们接收到的值。示例 9-13 中展示了一个定义 `Guess` 类型的方法,只有在 `new` 函数接收到 1 到 100 之间的值时才会创建 `Guess` 的实例: 相反我们可以创建一个新类型来将验证放入创建其实例的函数中,而不是到处重复这些检查。这样就可以安全地在函数签名中使用新类型并相信它们接收到的值。示例 9-13 中展示了一个定义 `Guess` 类型的方法,只有在 `new` 函数接收到 1 到 100 之间的值时才会创建 `Guess` 的实例:
```rust ```rust
{{#include ../listings/ch09-error-handling/listing-09-13/src/lib.rs:here}} {{#rustdoc_include ../listings/ch09-error-handling/listing-09-13/src/lib.rs:here}}
``` ```
<span class="caption">示例 9-13一个 `Guess` 类型,它只在值位于 1 和 100 之间时才继续</span> <span class="caption">示例 9-13一个 `Guess` 类型,它只在值位于 1 和 100 之间时才继续</span>

Loading…
Cancel
Save