-
Notifications
You must be signed in to change notification settings - Fork 817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support IntoPyObject for Arc in pyclass for pyo3(get) #4887
Comments
#4668 is somewhat related, but I think |
I think the question here is to define how to convert impl<'py, T> IntoPyObject<'py> for Arc<T>
where
for<'a> &'a T: IntoPyObject<'py>,
{
type Target = <??>::Target;
type Output = <??>::Output;
type Error = <??>::Error;
#[inline]
fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {
(&*self).into_pyobject(py)
}
} It is possible to implement on a reference, which would make it work for impl<'a, 'py, T> IntoPyObject<'py> for &'a Arc<T>
where
&'a T: IntoPyObject<'py>,
{
type Target = <&'a T as IntoPyObject<'py>>::Target;
type Output = <&'a T as IntoPyObject<'py>>::Output;
type Error = <&'a T as IntoPyObject<'py>>::Error;
#[inline]
fn into_pyobject(self, py: crate::Python<'py>) -> Result<Self::Output, Self::Error> {
(&**self).into_pyobject(py)
}
} I tend to think that writing a manual |
You can use additional type parameters. It is not pretty but it works 😅 impl<'py, A, T, O, E> IntoPyObject<'py> for std::sync::Arc<A>
where
for<'a> &'a A: IntoPyObject<'py, Target = T, Output=O, Error = E>,
O: BoundObject<'py, T>,
E: Into<PyErr>
{
type Target = T;
type Output = O;
type Error = E;
#[inline]
fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {
(&*self).into_pyobject(py)
}
} |
I defined a class
and I got the error below
`std::sync::Arc<std::vec::Vec<std::string::String>>` cannot be converted to a Python objec
The text was updated successfully, but these errors were encountered: