Tracking Issue for Integer Funnel Shifts
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Feature gate: #![feature(funnel_shifts)]
This is a tracking issue for implementation of funnel shifts on integers.
Funnel shifts are essentially a generalization of bitwise rotations. a.funnel_shl(b, n) means concatenate a and b (with a in the most significant half), creating an integer twice as wide, shifting this to the left by n (taken modulo the bit size of a and b), shifting in zeros, and finally extract the most significant half of the wide integer as the result.
The functions will panic if n >= T::BITS, and the wrapping versions consider n modulo T::BITS. The unchecked variant doesn't do any checks (as the name suggests), and so is unsafe.
a.wrapping_funnel_shl(a, n) is meant to be exactly equivalent to a.rotate_left(n).
Public API
impl {u8, u16, u32, u64, u128, usize} {
pub const fn funnel_shl(self, rhs: Self, shift: u32) -> Self;
pub const fn funnel_shr(self, rhs: Self, shift: u32) -> Self;
pub const fn wrapping_funnel_shl(self, rhs: Self, shift: u32) -> Self;
pub const fn wrapping_funnel_shr(self, rhs: Self, shift: u32) -> Self;
pub const unsafe fn unchecked_funnel_shl(self, rhs: Self, shift: u32) -> Self;
pub const unsafe fn unchecked_funnel_shr(self, rhs: Self, shift: u32) -> Self;
}
Steps / History
A SIMD version of these intrinsics were added in #142078
- ACP: https://github.com/rust-lang/libs-team/issues/642
- Implementation
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- Should we also provide these functions on signed integer types (akin to
rotates)?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Public API and Steps / History sections, then inspect implementation references #145690 and #154153. No file or test is named. The remaining work is the final comment period and stabilization PR, with the signed-integer question still unresolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100