Skip to content

Commit

Permalink
Relax constraints on PyArrowType (#4757)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold authored Aug 31, 2023
1 parent 735f48d commit eeba0a3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions arrow/src/pyarrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,15 @@ impl IntoPyArrow for ArrowArrayStreamReader {
/// A newtype wrapper around a `T: PyArrowConvert` that implements
/// [`FromPyObject`] and [`IntoPy`] allowing usage with pyo3 macros
#[derive(Debug)]
pub struct PyArrowType<T: FromPyArrow + IntoPyArrow>(pub T);
pub struct PyArrowType<T>(pub T);

impl<'source, T: FromPyArrow + IntoPyArrow> FromPyObject<'source> for PyArrowType<T> {
impl<'source, T: FromPyArrow> FromPyObject<'source> for PyArrowType<T> {
fn extract(value: &'source PyAny) -> PyResult<Self> {
Ok(Self(T::from_pyarrow(value)?))
}
}

impl<T: FromPyArrow + IntoPyArrow> IntoPy<PyObject> for PyArrowType<T> {
impl<T: IntoPyArrow> IntoPy<PyObject> for PyArrowType<T> {
fn into_py(self, py: Python) -> PyObject {
match self.0.into_pyarrow(py) {
Ok(obj) => obj,
Expand All @@ -312,7 +312,7 @@ impl<T: FromPyArrow + IntoPyArrow> IntoPy<PyObject> for PyArrowType<T> {
}
}

impl<T: FromPyArrow + IntoPyArrow> From<T> for PyArrowType<T> {
impl<T> From<T> for PyArrowType<T> {
fn from(s: T) -> Self {
Self(s)
}
Expand Down

0 comments on commit eeba0a3

Please sign in to comment.