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

feature: more Shl+Shr impls #328

Merged
merged 5 commits into from
Oct 13, 2023
Merged

feature: more Shl+Shr impls #328

merged 5 commits into from
Oct 13, 2023

Conversation

prestwich
Copy link
Collaborator

Motivation

Closes #327

Solution

Add Shl and Shr implementations for types that are losslessly castable to usize by re-using the existing usize implementation

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog

@prestwich prestwich added enhancement New feature or request refactor Can be written more cleanly labels Oct 3, 2023
@prestwich prestwich requested a review from gakonst October 3, 2023 22:33
Copy link
Collaborator

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

good w me, simple enough

@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Attention: 39 lines in your changes are missing coverage. Please review.

Comparison is base (6bd6a54) 80.78% compared to head (1f8c921) 80.45%.
Report is 1 commits behind head on main.

❗ Current head 1f8c921 differs from pull request most recent head 17f7300. Consider uploading reports for the commit 17f7300 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #328      +/-   ##
==========================================
- Coverage   80.78%   80.45%   -0.34%     
==========================================
  Files          54       54              
  Lines        6111     6053      -58     
==========================================
- Hits         4937     4870      -67     
- Misses       1174     1183       +9     
Files Coverage Δ
src/support/num_traits.rs 22.22% <ø> (+0.51%) ⬆️
src/bits.rs 74.61% <18.75%> (-3.22%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/bits.rs Outdated
self.wrapping_shr(*rhs)
}
}
impl_shift!(usize, u8, u16, u32, i8, i16, i32, isize);
Copy link
Contributor

Choose a reason for hiding this comment

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

u64/i64?

Copy link
Contributor

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

good w/ me! pending dani's nit

Comment on lines +703 to +705
// Only when losslessy castable to usize.
#[cfg(target_pointer_width = "64")]
impl_shift!(u64, i64);
Copy link
Contributor

Choose a reason for hiding this comment

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

below is lossless too, it just pads

@prestwich prestwich enabled auto-merge October 13, 2023 18:05
@prestwich prestwich merged commit 1c84b2d into main Oct 13, 2023
17 of 18 checks passed
@prestwich prestwich deleted the prestwich/shift branch October 13, 2023 18:09
@prestwich prestwich mentioned this pull request Oct 13, 2023
3 tasks
prestwich added a commit that referenced this pull request Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Can be written more cleanly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move Shl / Shr impls out of support into main lib
4 participants