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

mixed_integer_ops extension #386

Closed
davidzeng0 opened this issue May 28, 2024 · 1 comment
Closed

mixed_integer_ops extension #386

davidzeng0 opened this issue May 28, 2024 · 1 comment
Labels
ACP-accepted API Change Proposal is accepted (seconded with no objections) api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api

Comments

@davidzeng0
Copy link

davidzeng0 commented May 28, 2024

Proposal

Problem statement

Extend the methods added by rust-lang/rust#87840

#381 (comment)

The following subtraction methods are missing

impl uX {
    pub const fn checked_sub_signed(self, iX) -> Option<Self>;
    pub const fn overflowing_sub_signed(self, iX) -> (Self, bool);
    pub const fn saturating_sub_signed(self, iX) -> Self;
    pub const fn wrapping_sub_signed(self, iX) -> Self;
}

Motivating examples or use cases

The current best way to replicate checked_sub_signed is by

match signed.checked_neg() {
    Some(neg) => unsigned.checked_add_signed(neg),
    None => unsigned.checked_add(signed as Unsigned)
}

What happens now?

This issue contains an API change proposal (or ACP) and is part of the libs-api team feature lifecycle. Once this issue is filed, the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.

Possible responses

The libs team may respond in various different ways. First, the team will consider the problem (this doesn't require any concrete solution or alternatives to have been proposed):

  • We think this problem seems worth solving, and the standard library might be the right place to solve it.
  • We think that this probably doesn't belong in the standard library.

Second, if there's a concrete solution:

  • We think this specific solution looks roughly right, approved, you or someone else should implement this. (Further review will still happen on the subsequent implementation PR.)
  • We're not sure this is the right solution, and the alternatives or other materials don't give us enough information to be sure about that. Here are some questions we have that aren't answered, or rough ideas about alternatives we'd want to see discussed.
@davidzeng0 davidzeng0 added api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api labels May 28, 2024
@joshtriplett
Copy link
Member

We reviewed these in today's @rust-lang/libs-api meeting, and approved them.

@Amanieu Amanieu added the ACP-accepted API Change Proposal is accepted (seconded with no objections) label Jun 4, 2024
@Amanieu Amanieu closed this as completed Jun 4, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 13, 2024
…ned_sub, r=Amanieu

Implement `mixed_integer_ops_unsigned_sub`

Implement rust-lang#126043

ACP: rust-lang/libs-team#386 [Accepted]
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 14, 2024
Rollup merge of rust-lang#126046 - davidzeng0:mixed_integer_ops_unsigned_sub, r=Amanieu

Implement `mixed_integer_ops_unsigned_sub`

Implement rust-lang#126043

ACP: rust-lang/libs-team#386 [Accepted]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ACP-accepted API Change Proposal is accepted (seconded with no objections) api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api
Projects
None yet
Development

No branches or pull requests

3 participants