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

Implement OpAssign traits with references on the right hand side #32094

Closed
bluss opened this issue Mar 7, 2016 · 5 comments
Closed

Implement OpAssign traits with references on the right hand side #32094

bluss opened this issue Mar 7, 2016 · 5 comments
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@bluss
Copy link
Member

bluss commented Mar 7, 2016

AddAssign and the others are only implemented for equal right hand side arguments. AddAssign<u32> for u32 works well for integers, but the by reference Rhs implementation is important too, so that bigints and other non-Copy data types can have some interface in common with the primitive number types.

@nodakai
Copy link
Contributor

nodakai commented Mar 21, 2016

By not providing AddAssign<&i32>, you can assume where T: AddAssign<T> applies to lightweight/primitive numbers and where T: AddAssign<&T> applies to bignums

@ottworks
Copy link

Creates inconsistencies between x = x / y and x /= y, requiring an unnecessary dereference for iteration: https://is.gd/DIyCYY

@bluss
Copy link
Member Author

bluss commented Aug 11, 2016

@nodakai Then generic code can only handle either of them, but not both.

@steveklabnik steveklabnik added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed A-libs labels Mar 24, 2017
@alexcrichton
Copy link
Member

alexcrichton commented Jun 8, 2017

This was attempted in #41336 but unfortunately it caused too much breakage, so I'm going to close.

@alexcrichton alexcrichton added the rust-2-breakage-wishlist In the wishlist of breaking changes that requires rust 2.0 label Jun 8, 2017
@OnlyLys
Copy link

OnlyLys commented Aug 12, 2019

Heads up for future readers, this was fixed in Rust 1.22.0.

@dtolnay dtolnay removed the rust-2-breakage-wishlist In the wishlist of breaking changes that requires rust 2.0 label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

7 participants