From 4ea391adf3089aee52dcab3965da068618c277cb Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 28 Jan 2025 13:43:11 -0500 Subject: [PATCH] update `PyStreamable` to provide `IntoPyObject()` --- crates/chia_py_streamable_macro/src/lib.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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()) } } }