Skip to content
Update rust error authored by umaumax's avatar umaumax
......@@ -59,7 +59,7 @@ extern crate anyhow;
サーベイはこちら
[Error Handling Survey]( https://blog.yoshuawuyts.com/error-handling-survey/ )
### thiserror
## thiserror
``` rust
use std::fs::File;
......@@ -101,7 +101,7 @@ pub enum MyError {
}
```
#### `anyhow::Error`から`thiserror`への移行方法
### `anyhow::Error`から`thiserror`への移行方法
方針
* `anyhow::Result``Box<dyn std::error::Error>``pub type Result<T, E = MyError> = std::result::Result<T, E>;`へ置き換える
* 既存のエラー型を受け入れられる`thiserror`のエラー型を`Anyhow(#[from] anyhow::Error)`のようにして作成する
......
......