feat for issue #809: impl std::error::Error for cursive::theme::Error
https://github.com/gyscos/cursive/issues/809 had been opened inquiring about implementing `std::error::Error` for `cursive::theme::Error` so they could do something like this:
```
fn load_theme(siv: &mut CursiveRunnable, path: PathBuf) -> anyhow::Result<()> {
siv.load_theme_file(path)?;
Ok(())
}
```
Instead of having to do this:
```
fn load_theme(siv: &mut CursiveRunnable, path: PathBuf) -> anyhow::Result<()> {
match siv.load_theme_file(path) {
Ok(_) => Ok(()),
Err(e) => match e {
cursive::theme::Error::Io(e) => Err(e.into()),
cursive::theme::Error::Parse(e) => Err(e.into()),
}
}
}
```
It seemed like low hanging fruit, so I figured I'd offer up a PR. Included some tests for the different `Error::Io`, `Error::Parse` and `?` cases.
Thank you for considering this change!
合并状态:未合并 4 条评论