Open davidhewitt opened 1 week ago
I haven't looked at the impl, but FWIW what I do in rust-asn1
is to look if the struct already has a lifetime, and if so use that lifetime.
The reason for the special case is that we do support lifetimes other than 'py
, eg this works:
#[derive(IntoPyObject)]
struct Foo<'a>(&'a str);
But I can have a look if there is a way to improve the error message.
Yes, I thought it was something like that special case where the lifetime is unrelated 👍
One thought I had is that maybe with GATs
the lifetime would be unnecessary on the trait and could go on the Output
associated type. Covariance might allow things to just work. That's a future possibility though rather than something we can use now.
In
pydantic-core
some (legacy) lifetimes were'a
instead of'py
, and using the new#[derive(IntoPyObject)]
led to some interesting errors:gets lots of errors like
changing the struct lifetime from
'a
to'py
trivially resolves, though I wonder if there's any tricks we can do to improve the UX 🤔