condensed duplicate code for trait specialization using macros#424
condensed duplicate code for trait specialization using macros#424hclarke wants to merge 1 commit intorustgd:masterfrom
Conversation
|
ping! @brendanzab have any thoughts on this one? I mainly did it because the first PR I submitted failed on the simd travis builds the first time, and I had to fix it by duplicating code. Doing it this way means that changes to the trait implementations only need to happen in one place, so it should reduce friction on future patches |
|
Woopsie, sorry I looked, thought it was awesome, then forgot to reply! Yeah, I re-read the simd stuff a while back and got a tad confused. In fact I think a whole lot of our macro stuff is a bit ugly, so I'm glad you've been looking into it! |
| #![macro_use] | ||
|
|
||
| /// generates an impl fn, allowing specialization if simd is enabled | ||
| macro_rules! impl_fn { |
There was a problem hiding this comment.
Think I'd prefer this called impl_operator_method!
| /// generates an impl fn, allowing specialization if simd is enabled | ||
| macro_rules! impl_fn { | ||
|
|
||
|
|
|
these changes are in my queue. will probably get to it in the next few days |
|
@hclarke looks like the few days got stretched quite a bit :) |
I put all the "default" keyword stuff into a impl_fn! macro. that way, there's way less duplicate code for simd trait implementations
I also feel like there should be a "specialization" or "nightly" feature that's separate from "simd" (that simd enables/depends on). This patch doesn't include that, but makes it easier to implement, since there's only one macro to change
also made a BaseSigned trait so that you can use the trait implementation macros for Neg