-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Proposal: Implement assignment operator overloads #393
Comments
Q: Why did you remove |
Overloading |
(noob) Q: Does rust provide any way of doing something like this right now?: let my_big_num: BigNum = 42; Basically, to be able to assign "constants" to objects and have it work? |
And I think for that, you'd rather want to push for making number literals generic, so that that turns into something like |
Should default trait implementations like this be provided? impl<R, T> AddAssign<R> for T
where T: Add<R> {
fn add_assign(&mut self, &rhs: R) { *self = self + rhs; }
} 👍 for this either way. |
This is done! |
Fixed some grammar and spelling
Issue by bjz
Sunday Apr 21, 2013 at 22:16 GMT
For earlier discussion, see rust-lang/rust#5992
This issue was labelled with: A-libs, A-traits, I-enhancement, P-low in the Rust repository
This would be very useful for
core::num
(see #4819), and also mathematics libraries.It would also be useful to be able to assign to values accessed via the index operator. This would return a mutable reference to the element. =, +=, -=, *=, /=, and %= would then be based off the overloads defined for that element type.
Edit: Removed
Assign
trait for=
operator.The text was updated successfully, but these errors were encountered: