Simplify a few Option / Result pattern-matches

This commit is contained in:
François Garillot
2020-02-05 06:51:03 -08:00
parent 9770be5661
commit 42bc3cb21f
8 changed files with 18 additions and 46 deletions

View File

@ -23,9 +23,6 @@ impl std::error::Error for PyError {}
pub struct ToPyResult<T>(pub Result<T>);
impl<T> std::convert::Into<PyResult<T>> for ToPyResult<T> {
fn into(self) -> PyResult<T> {
match self.0 {
Ok(o) => Ok(o),
Err(e) => Err(exceptions::Exception::py_err(format!("{}", e))),
}
self.0.map_err(|e| { exceptions::Exception::py_err(format!("{}", e)) })
}
}