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 *Assign ops #19

Merged
merged 2 commits into from Feb 2, 2022
Merged

Implement *Assign ops #19

merged 2 commits into from Feb 2, 2022

Conversation

adamgreig
Copy link
Contributor

Implements +=, -=, *=, and /= where appropriate, by using the existing +, -, *, and / operators.

This allows for example:

let mut t = MillisDurationU64::millis(100);
t += MillisDurationU64::millis(900);

instead of what's currently required:

let mut t = MillisDurationU64::millis(100);
t = t + MillisDurationU64::millis(900);

Sorry if this has been considered before, I couldn't find any previous discussions. I tried to add it wherever it makes sense alongside an existing operator implementation.

@korken89
Copy link
Owner

korken89 commented Feb 1, 2022

Awesome, could you add one of each to the tests and update the CHANGELOG?

And thanks for adding! I had completely forgotten this!

@adamgreig
Copy link
Contributor Author

adamgreig commented Feb 2, 2022

Thanks! I've added tests (and a few extra tests for the non-assign versions where I couldn't find them, for Duration * u32, Duration / u32, Instant + Duration, Instant - Duration).

Copy link
Owner

@korken89 korken89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for fixing!

@korken89
Copy link
Owner

korken89 commented Feb 2, 2022

bors merge

@bors
Copy link
Contributor

bors bot commented Feb 2, 2022

Build succeeded:

@bors bors bot merged commit fa48086 into korken89:master Feb 2, 2022
@adamgreig adamgreig deleted the assign-ops branch February 2, 2022 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants