Skip to content
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

It isn't possible to compare primitives with references of the same type #77374

Closed
c410-f3r opened this issue Sep 30, 2020 · 3 comments
Closed
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@c410-f3r
Copy link
Contributor

c410-f3r commented Sep 30, 2020

There are implementations of arithmetic operators like Add, Sub or Div for owned primitives mixed with references, however, comparison operators are only available for a single T.

Is there a technical decision preventing, e.g., impl PartialEq<&usize> for usize? It would be nice to be able to write 10i32 > some_i32_ref_var instead of 10i32 > *some_i32_ref_var.

@camelid camelid added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Sep 30, 2020
@camelid
Copy link
Member

camelid commented Sep 30, 2020

I believe this is a duplicate of #44619.

@scottmcm
Copy link
Member

scottmcm commented Oct 1, 2020

Beware that more impls often causes type inference problems -- the most recent example I remember is #76189 -- though it's possible that the distinction between primitives and references might be enough to avoid that in these cases.

The question about whether these are desirable, or if so whether they should be more impls or making sides of operators deref sites or ________ is a harder question.

@c410-f3r
Copy link
Contributor Author

Closing due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants