mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-02-02 15:28:40 +08:00
Update src/ch09-02-recoverable-errors-with-result.md
This commit is contained in:
parent
dfd4200333
commit
68de3660f8
@ -176,7 +176,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`expect` 与 `unwrap` 的使用方式一样:返回文件句柄或调用 `panic!` 宏。`expect` 用来调用 `panic!` 的错误信息将会作为参数传递给 `expect` ,而不像`unwrap` 那样使用默认的 `panic!` 信息。它看起来像这样:
|
`expect` 与 `unwrap` 的使用方式一样:返回文件句柄或调用 `panic!` 宏。`expect` 在调用 `panic!` 时使用的错误信息将是我们传递给 `expect` 的参数,而不像`unwrap` 那样使用默认的 `panic!` 信息。它看起来像这样:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
thread 'main' panicked at 'Failed to open hello.txt: Error { repr: Os { code:
|
thread 'main' panicked at 'Failed to open hello.txt: Error { repr: Os { code:
|
||||||
|
Loading…
Reference in New Issue
Block a user