-
Notifications
You must be signed in to change notification settings - Fork 250
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
Impl sub, mul and div for actual objects #843
Impl sub, mul and div for actual objects #843
Conversation
Co-authored-by: Antonio Mejías Gil <[email protected]>
Co-authored-by: Antonio Mejías Gil <[email protected]>
Co-authored-by: Antonio Mejías Gil <[email protected]>
@Pratyush @mmagician Decision needed We realised the previous implementation of operators *, /, - for owned In the specific example given, the reason for the new failure is that, when operators (say, This indicated us that the best way to ensure the new operator definitions were not a breaking change was to implement However, that introduced another breaking change. I'm gonna explain why I think it fails now, although it is quite subtle. It's easier to just try to compile e.g. My guess as to the issue: In the case of Possible approaches: We either find a way to fix that problem (I can't see how), admit this breaking change into |
Rust does not coerce types to their references, except for Appears this page does not explain this aspect of reference promotion : This restriction is implicit in this sentence however:
|
What happens if we change those types to use the operators? I.e l_poly * xyz or whatever? |
@burdges Thanks for the resources! I realized that, apparently, the method invocation After further inspection, I agree with @Antonio95 about what happens in
Once we introduce @Pratyush Do you mean replacing the call to |
Yeah, that's bizarre. I'd thought the restriction came from the implemented type, but no it really searches the whole space of methods. If you've so many |
Wow, very interesting pointers (no pun intended) to the docs and examples, @burdges . Thanks a lot! The coercion decisions seem tricky to pin down. @Cesar199999 and I will test a couple of ideas, but I'm not super confident. |
@Burdge It can get even more bizarre... I just noticed that using the fully qualified syntax in the For a TL;DR of the whole issue, @Antonio95 came up with the following example that sums up how the compiler handles the coercion. In short, adding any @Pratyush The only two remaining options are (1) forget about this PR (2) change the line in |
I think better to rely on explicit annotation of references than relying on implicit coercions which can break from innocuous changes in dependencies. I think this is fine anyway because 0.5.0 has other breaking changes. |
Co-authored-by: Antonio Mejías Gil <[email protected]>
Description
Adds support for arithmetic operations on actual objects
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
Pending
section inCHANGELOG.md
Files changed
in the GitHub PR explorer