Skip to content

Implement operations for Wrapping<T> where Rhs = T #140567

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kriskras99
Copy link
Contributor

Currently doing the following is not possible:

let n = Wrapping(142usize);
let m = n % 100;

It is however possible to do:

let mut n = Wrapping(142usize);
n %= 100;

In the spirit of Is an RFC required? this seems like an obvious API hole. Therefore I've implemented this without an RFC. I am willing to write an RFC if it is required though.

I could not figure out where/how to implement tests for this, so if someone could please tell me where and how to do that.

Somewhat related issues: #91586 #32463

@rustbot
Copy link
Collaborator

rustbot commented May 1, 2025

r? @thomcc

rustbot has assigned @thomcc.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 1, 2025
@cuviper
Copy link
Member

cuviper commented May 2, 2025

r? libs-api

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label May 2, 2025
@rustbot rustbot assigned dtolnay and unassigned thomcc May 2, 2025
@dtolnay dtolnay removed the T-libs Relevant to the library team, which will review and decide on the PR/issue. label May 3, 2025
@dtolnay
Copy link
Member

dtolnay commented May 25, 2025

Thanks for the PR!

This comment explains why these impls were initially not provided: #93208 (comment).

I think the rationale still holds, but I don't have a strong opinion either way. Adding the set of impls in this PR would make things slightly worse for some users and slightly better for some users.

@rfcbot fcp close

@rfcbot
Copy link
Collaborator

rfcbot commented May 25, 2025

Team member @dtolnay has proposed to close this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-close This PR / issue is in PFCP or FCP with a disposition to close it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels May 25, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented May 29, 2025

🔔 This is now entering its final comment period, as per the review above. 🔔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-close This PR / issue is in PFCP or FCP with a disposition to close it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants