-
Notifications
You must be signed in to change notification settings - Fork 257
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
Implement operator overloading methods (for external opaque types) #1924
Comments
Hi! Thanks for opening your first issue here! 😄 |
Looks pretty reasonable! One way may be the rename you mentioned, and another way may be utilize the Btw I am not very sure, where do you want to add |
I meant |
I see. Indeed IIRC that is optional - the linter will be unhappy without it, but it is just linter instead of compiler, and you can |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue. |
I am implementing a derivation of a Semver in rust. Since there's a fair bit of logic behind it, I want to implement it as an opaque type.
And since the type is implemented in an external rust crate (from: https://cjycode.com/flutter_rust_bridge/guides/miscellaneous/methods), it looks like this:
Now, I'd like to be able to use the dart comparison overloads (
==
,>
,=>
, etc) to make the api nicer to work with (Strict reference/pointer equality is not important). In the docs, you describe that this can be implemented using arbitrarydart_code
(https://cjycode.com/flutter_rust_bridge/guides/miscellaneous/dart-code). However, that annotation seems only usable on struct definitions, not onimpl
blocks.I think that, ideally, operators should be first-class citizens, much like pyo3 handles magic functions. Probably even something simple like function renaming
#[frb(name="operator==")]
would work, although then you'd still need to somehow declare the need for@overload
.What do you think?
The text was updated successfully, but these errors were encountered: