diff --git a/eden/scm/edenscmnative/bindings/modules/pydag/src/lib.rs b/eden/scm/edenscmnative/bindings/modules/pydag/src/lib.rs index e4f4e1a413..7f862aa633 100644 --- a/eden/scm/edenscmnative/bindings/modules/pydag/src/lib.rs +++ b/eden/scm/edenscmnative/bindings/modules/pydag/src/lib.rs @@ -9,7 +9,7 @@ use anyhow::Error; use cpython::*; -use cpython_ext::{FallibleExt, ResultPyErrExt}; +use cpython_ext::{AnyhowResultExt, ResultPyErrExt}; use dag::{ id::{Group, Id}, idmap::IdMap, @@ -343,13 +343,13 @@ fn translate_get_parents<'a>( move |node: &[u8]| -> Result>> { let mut result = Vec::new(); let node = PyBytes::new(py, node); - let parents = get_parents.call(py, (node,), None).into_fallible()?; - for parent in parents.iter(py).into_fallible()? { + let parents = get_parents.call(py, (node,), None).into_anyhow_result()?; + for parent in parents.iter(py).into_anyhow_result()? { let parent = parent - .into_fallible()? + .into_anyhow_result()? .cast_as::(py) .map_err(PyErr::from) - .into_fallible()? + .into_anyhow_result()? .data(py) .to_vec() .into_boxed_slice(); diff --git a/eden/scm/lib/cpython-ext/src/error.rs b/eden/scm/lib/cpython-ext/src/error.rs index fec40c98be..dd2451f6e0 100644 --- a/eden/scm/lib/cpython-ext/src/error.rs +++ b/eden/scm/lib/cpython-ext/src/error.rs @@ -16,7 +16,7 @@ use std::fmt; /// Extends the `Result` type to allow conversion to `PyResult` from a native /// Rust result. /// -/// If the error is created via [`FallibleExt`], the original Python error +/// If the error is created via [`AnyhowResultExt`], the original Python error /// will be returned. /// /// # Examples @@ -48,26 +48,26 @@ pub trait ResultPyErrExt { /// /// ``` /// use anyhow::Result; -/// use cpython_ext::error::{FallibleExt, PyErr}; +/// use cpython_ext::error::{AnyhowResultExt, PyErr}; /// /// fn eval_py() -> Result { /// let gil = cpython::Python::acquire_gil(); /// let py = gil.python(); -/// let obj = py.eval("1 + 2", None, None).into_fallible()?; -/// obj.extract(py).into_fallible() +/// let obj = py.eval("1 + 2", None, None).into_anyhow_result()?; +/// obj.extract(py).into_anyhow_result() /// } /// /// fn round_trip() -> cpython::PyResult<()> { /// let gil = cpython::Python::acquire_gil(); /// let py = gil.python(); -/// let res = py.eval("1 + 2", None, None).into_fallible(); +/// let res = py.eval("1 + 2", None, None).into_anyhow_result(); /// use cpython_ext::error::ResultPyErrExt; /// res.map(|_| ()).map_pyerr(py) /// } /// ``` /// -pub trait FallibleExt { - fn into_fallible(self) -> Result; +pub trait AnyhowResultExt { + fn into_anyhow_result(self) -> Result; } py_exception!(error, PyIndexedLogError); @@ -98,8 +98,8 @@ impl> ResultPyErrExt for Result { } } -impl FallibleExt for PyResult { - fn into_fallible(self) -> Result { +impl AnyhowResultExt for PyResult { + fn into_anyhow_result(self) -> Result { self.map_err(|e| Error::new(PyErr::from(e))) } } diff --git a/eden/scm/lib/cpython-ext/src/lib.rs b/eden/scm/lib/cpython-ext/src/lib.rs index 95129e6af5..9c00396746 100644 --- a/eden/scm/lib/cpython-ext/src/lib.rs +++ b/eden/scm/lib/cpython-ext/src/lib.rs @@ -16,7 +16,7 @@ pub mod ser; pub use crate::bytearrayobject::{boxed_slice_to_pyobj, vec_to_pyobj}; pub use crate::bytesobject::allocate_pybytes; -pub use crate::error::{format_py_error, FallibleExt, PyErr, ResultPyErrExt}; +pub use crate::error::{format_py_error, AnyhowResultExt, PyErr, ResultPyErrExt}; pub use crate::io::{wrap_pyio, WrappedIO}; pub use crate::pybuf::SimplePyBuf; pub use crate::pyset::{pyset_add, pyset_new};