diff --git a/crates/chia_py_streamable_macro/src/lib.rs b/crates/chia_py_streamable_macro/src/lib.rs index 9edb3ce06..7d6b8efd9 100644 --- a/crates/chia_py_streamable_macro/src/lib.rs +++ b/crates/chia_py_streamable_macro/src/lib.rs @@ -54,15 +54,15 @@ pub fn py_streamable_macro(input: proc_macro::TokenStream) -> proc_macro::TokenS } } - impl pyo3::conversion::ToPyObject for #ident { - fn to_object(&self, py: pyo3::Python<'_>) -> pyo3::PyObject { - pyo3::conversion::ToPyObject::to_object(&(*self as u8), py) - } - } - - impl pyo3::conversion::IntoPy for #ident { - fn into_py(self, py: pyo3::Python<'_>) -> pyo3::PyObject { - pyo3::conversion::ToPyObject::to_object(&(self as u8), py) + impl<'py> pyo3::conversion::IntoPyObject<'py> for #ident { + type Target = pyo3::PyAny; + type Output = pyo3::Bound<'py, Self::Target>; + type Error = std::convert::Infallible; + + fn into_pyobject(self, py: pyo3::Python<'py>) -> Result { + Ok(pyo3::IntoPyObject::into_pyobject(self as u8, py)? + .clone() + .into_any()) } } }