-
Notifications
You must be signed in to change notification settings - Fork 77
Lighter-weight support for Uint concat, split operations
#1191
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1191 +/- ##
==========================================
+ Coverage 86.93% 87.24% +0.31%
==========================================
Files 182 182
Lines 20528 20561 +33
==========================================
+ Hits 17845 17939 +94
+ Misses 2683 2622 -61 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Nice! Getting rid of the |
|
I also had a shot at using |
|
Hmm, it looks like this would also be a breaking change for |
|
I've done some testing with a new typenum-like crate which allows the removal of impl<const LIMBS: usize> Uint<LIMBS> {
pub const fn split<const HALF_LIMBS: usize>(&self) -> (Uint<HALF_LIMBS>, Uint<HALF_LIMBS>)
where Self: SplitEven<Output=Uint<HALF_LIMBS>>;
pub const fn split_mixed<const LO_LIMBS: usize, const HI_LIMBS: usize>(&self) -> (Uint<LO_LIMBS>, Uint<HI_LIMBS>)
where Self: Split<LO_LIMBS, Output=Uint<HI_LIMBS>>;
pub const fn concat<const WIDE_LIMBS: usize>(&self, hi: &Uint<LIMBS>) -> Uint<WIDE_LIMBS>
where Self: Concat<LIMBS, Output=Uint<WIDE_LIMBS>>;
pub const fn concat_mixed<const HI_LIMBS, const WIDE_LIMBS: usize>(&self, hi: &Uint<HI_LIMBS>) -> Uint<WIDE_LIMBS>
where Self: Concat<HI_LIMBS, Output=Uint<WIDE_LIMBS>>;
} |
|
@andrewwhitehead why'd you set this back to draft? (I mean, it seems to have conflicts, but...) |
|
I'd like to modify the traits a bit, so they wouldn't need to be changed again (hopefully) and are a bit easier to use. |
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
94d624b to
c75999c
Compare
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be curious if there's a way to unify something like this with ArrayEncoding but I'll leave that for a followup.
This also moves
EncodedUint<->[u8; N]conversion out of the macro rules for different Uint sizes. TheConcat,Split, andSplitMixedtraits are changed to define the output types only, while theConcatMixedtrait is removed as unnecessary. In all, this seems to have a positive effect on build times. New tests are added to ensure that result types can be inferred when it is useful.Related to #1095