-
Notifications
You must be signed in to change notification settings - Fork 148
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
Support the assignment operator traits like AddAssign
#173
Comments
Yes supporting the assign operators would be great! |
Yeah, I think |
Assign traits have a problem we need to solve in libstd first I think: There's no I think it must be weighed if the op assign traits are not so important that maybe they should be added everywhere. |
Would this crate accept pull requests implementing compound assignment operators for individual types (say, |
@bluss started Hiding them behind an "opassign" feature seems like a good start though, so we don't even have to raise the rustc baseline. I think it's fine to deal with each type in separate PRs. |
Hearing that makes me cautiously optimistic. 😄 There seems to be two issues in this issue (no order)
I don't think the traits have a nice way to use a crate feature to flip their behavior (would it need adding new traits, like FloatOpAssign or so?) |
So, #263 bumped us to Rust 1.8 now... |
Is there an issue upstream tracking this? I just ran into this today writing a generic factorial function :( |
There's actually an open PR right now, rust-lang/rust#41336. |
Does |
Adding that constraint to |
I worked around this by implementing my own Float trait. |
|
These have been recently stabilized in rust-lang/rust#28235. We should at least add support for these to our concrete types.
We may also want to require them in our traits where we already require the basic
Add
etc., although I'm not sure if that's too much to impose on outside types implementing our traits. It could instead be something new likeNumAssign: Num + AddAssign + SubAssign + ...
We'll have to raise our baseline Rust version to 1.8 (once it's released) to support assignment operators, but this feature may be useful enough to finally justify moving up. That would also enable a few other changes we've had blocked on Rust 1.0.
The text was updated successfully, but these errors were encountered: