-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Add FromValueDelegate #987
Conversation
eb386cd
to
fbf7669
Compare
@@ -369,20 +369,6 @@ pub trait ToValue { | |||
fn value_type(&self) -> Type; | |||
} | |||
|
|||
// rustdoc-stripper-ignore-next | |||
/// Blanket implementation for all references. | |||
impl<T: ToValue + StaticType> ToValue for &T { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to remove this to auto-implement ToValue
for T: ValueDelegate
. Else they were in conflict.
The tests don't complain so... 🤷🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes it impossible to pass &Object
to e.g. Object::set_property()
and only Object
would work
Add FromValueDelegate
fbf7669
to
2bfd058
Compare
Uh oh, we don't have GATs in rust 1.64, only from 1.65. 😢 That ValueDelegate trait implementation will require a |
For the next release we can update to 1.65 but that won't do for backporting :) |
I don't think this can be backported anyway? It removes a trait impl and I'm not sure the new one covers the cases the old trait impl did |
So, in brief, implementing this with traits is impossible. To keep the old ToValue implementation for Fortunately, we have macros! And that would work for every rust version. |
I think that makes sense. It's even less user code than implementing a trait manually ;) |
#1000 has the macro approach |
Makes implementing
FromValue
safe and trivial