rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.61k stars 12.74k forks source link

Tracking Issue for unbounded_shifts #129375

Open chorman0773 opened 2 months ago

chorman0773 commented 2 months ago

Feature gate: #![feature(unbounded_shifts)]

This is a tracking issue for ACP 428.

This adds shifts functions to the integer types that ignore type bounds when shifting, with out of range values for the rhs yielding the result of shifting the entire value out (0 for left shifts, and unsigned right shifts, and either 0 or -1 for signed right shifts).

Public API

impl uN{
     pub const fn unbounded_shl(self, rhs: u32) -> Self;
     pub const fn unbounded_shr(self, rhs: u32) -> Self;
}

impl iN{
    pub const fn unbounded_shl(self, rhs: u32) -> Self;
    pub const fn unbounded_shr(self, rhs: u32) -> Self;
}

Steps / History

Unresolved Questions

joshtriplett commented 4 days ago

This seems ready to stabilize.

@rfcbot merge

rfcbot commented 4 days ago

Team member @joshtriplett has proposed to merge 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.

chorman0773 commented 4 days ago

I was going to do a stabilization report.

Just to be clear, my intention was to stabilize it both as a function and as a const fn in one shot, so team should keep that in mind during the pFCP.